package com.zegome.game.gomestory.main.helper;

import java.util.Vector;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import aurelienribon.tweenengine.BaseTween;
import aurelienribon.tweenengine.Tween;
import aurelienribon.tweenengine.TweenCallback;
import aurelienribon.tweenengine.TweenManager;
import aurelienribon.tweenengine.equations.Quad;
import aurelienribon.tweenengine.equations.Quart;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle;
import com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox.CheckBoxStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton.ImageButtonStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.Align;
import com.badlogic.gdx.scenes.scene2d.utils.BaseDrawable;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.zegome.facebook.IFacebookProcessorListener;
import com.zegome.game.gomestory.MainActivity;
import com.zegome.game.gomestory.main.Center;
import com.zegome.game.gomestory.main.D;
import com.zegome.game.gomestory.main.scene.BaseGameScreen;
import com.zegome.game.gomestory.main.scene.vs.VSScreen;
import com.zegome.game.util.helper.WidgetAccessor;
import com.zegome.payment.appota.IAppotaPaymentProcessorListener;
import com.zegome.payment.appota.ISmsProcessor;

/**
 * (C) 2013 ZeroTeam
 * 
 * @author QuanLT
 */

public class StageHelper {	
	
	private static final String LINK_RESET = "http://zegome.com/gomestory/mobile/user/forget-password";
	
	private static final String GOOGLE_LINK = "https://play.google.com/store/apps/details?id=com.zegome.game.gomestory";
	private static final String APPOTA_LINK = "http://appstore.vn/android/index.php/details?id=com.zegome.game.gomestory";
	private static final String DESCRIPTION = "Quá tuyệt để giải trí";
	private static final String CAPTION = "Hấp dẫn và thú vị";
	private static final String URL = "http://farm4.staticflickr.com/3667/10670849985_85d29674a1_o.png";
	private static final String NAME = "Gome Story";
	
	private static final String deepLink = "https://play.google.com/store/apps/details?id=com.zegome.game.gomestory";
    private static final String message = "Play this fun game. I gave you 500 diamonds!";
    private static final String data = "{\"diamond\":\"500\"}";
	
	Center ctr;
	public Image avatar;
	public Image diamond;
	public Table infoUserFrame=null;	
	public Label moneyStr, nameStr;
	public Table dialogLoading;	
	public Label require;	
	public ImageButton reg,login;
	
	public StageHelper(Center ctr){
		this.ctr = ctr;
	}
	
	public void dispose(){
		diamond = null;
		infoUserFrame = null;
		moneyStr = null;
		nameStr = null;
		dialogLoading = null;
		require = null;
		reg = null;
		login = null;
	}
	
	public void removeRequire(){
		if(require != null){
			require.remove();
			require = null;
		}
		if(reg!=null){
			reg.remove();
			reg = null;
		}
		if(login!=null){
			login.remove();
			login = null;	
		}
	}
		
	public Table createTable(final Skin skin, final float x, final float y,
			final float width, final float height) {
		final Table table = new Table(skin);
		table.setPosition(x, y);
		table.setSize(width, height);
		return table;
	}
	
	public MTable createMTable(final Skin skin, final float x, final float y,
			final float width, final float height) {
		final MTable table = new MTable();
		table.setPosition(x, y);
		table.setSize(width, height);
		return table;
	}
	
	public Table createTableWithTransBg(final Skin skin, final float x, final float y,
			final float width, final float height){
		final Table table = new Table(skin);
		table.setPosition(x, y);
		table.setSize(width, height);

		BaseDrawable bg = new BaseDrawable();
		bg.setMinWidth(width);
		bg.setMinHeight(height);
		table.setBackground(bg);

		return table;
	}
	
	public ImageButton createImageButton(final Skin skin,
			final TextureRegion imageUp, final TextureRegion imageDown,
			final TextureRegion imageDisable, final float x, final float y) {
		return createImageButton(ctr.g.mSkin, imageUp, imageDown, imageDisable, x, y, (imageUp.getRegionWidth()), (imageUp.getRegionHeight()));
	}
			
	public ImageButton createImageButton(final Skin skin,
			final TextureRegion imageUp, final TextureRegion imageDown,
			final TextureRegion imageDisable, final float x, final float y, float wi, float hi) {
		final ImageButtonStyle style = new ImageButtonStyle(skin.get("trans", ButtonStyle.class));
		boolean ok = false;
		if (imageUp != null) {
			style.imageUp = new TextureRegionDrawable(imageUp);
			style.imageUp.setMinWidth(wi);
			style.imageUp.setMinHeight(hi);
			ok = true;
		}
		if (imageDown != null) {
			style.imageDown = new TextureRegionDrawable(imageDown);
			style.imageDown.setMinWidth(wi);
			style.imageDown.setMinHeight(hi);
			if (!ok) ok = true;
		}
		if (imageDisable != null) {
			style.imageDisabled = new TextureRegionDrawable(imageDisable);
			style.imageDisabled.setMinWidth(wi);
			style.imageDisabled.setMinHeight(hi);
			if (!ok) ok = true;
		}
		if (!ok) {
			throw new IllegalArgumentException("One of regions must be different from null");
		}
		final ImageButton button = new ImageButton(style);
		button.setPosition(x, y);
		return button;
	}
	
	public Image createImage(final TextureRegion region, final float x, final float y) {
		if (region == null) {
			throw new IllegalArgumentException("region must be different from null");
		}
		return createImage(region, x, y, (region.getRegionWidth()), (region.getRegionHeight()));
	}
	
	public Image createImage(final TextureRegion region, final float x, final float y, final float width, final float height) {
		if (region == null) {
			throw new IllegalArgumentException("region must be different from null");
		}
		final Image image = new Image(region);
		image.setPosition(x, y);
		image.setSize(width, height);
		return image;
	}
	
	public Label createLabel(final BitmapFont font, final String s, final Color color, final float x, final float y)
	{
		LabelStyle style = new LabelStyle(font, color);
		Label text = new Label(s, style);
		text.setPosition(x, y);
		return text;
	}
	
	public CheckBox createCheckBox(final BitmapFont font, final TextureRegion on, final TextureRegion off)
	{
		return createCheckBox(font, on, off,on.getRegionWidth(),on.getRegionHeight());
	}
	
	public CheckBox createCheckBox(final BitmapFont font, final TextureRegion on, final TextureRegion off, int wi,int hi)
	{
		CheckBox i=null;
		CheckBoxStyle style = new CheckBoxStyle();
		style.checkboxOn = new TextureRegionDrawable(on);
		style.checkboxOn.setMinWidth(wi);
		style.checkboxOn.setMinHeight(hi);
		style.checkboxOff = new TextureRegionDrawable(off);
		style.checkboxOff.setMinWidth(wi);
		style.checkboxOff.setMinHeight(hi);
		style.font = font;
		i = new CheckBox("", style);
		return i;
	}
		
	public Table createAvatar(final BaseGameScreen screen, final Stage stage, final TweenManager tweenManager, float x, float y, float scale){						
		ImageButton transBut = createImageButton(ctr.g.mSkin, ctr.a.transRegion, ctr.a.transRegion, null, 0, 0, 131, 99);	
		transBut.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {											
				if(ctr.a.isHasDialog())
					return;				
				createPopupAvatar(screen,stage, tweenManager);
			}		
		});
		
		infoUserFrame = createTableWithTransBg(ctr.g.mSkin, 0, 0, (244), (99));	
		avatar = createImage(ctr.a.avatarMe, (10), (13),(72), (72));
		infoUserFrame.addActor(createImage(ctr.a.avatarFrame, 0, 0,(244), (99)));
		infoUserFrame.addActor(avatar);	
		infoUserFrame.addActor(createImage(ctr.a.boderAvatar, 6, 9, 72+8, 72+8));
		
		moneyStr = createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0);
		moneyStr.setText("12345");
		moneyStr.setPosition(110, 47);
		
		nameStr = createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0);
		nameStr.setText("ZeGome");
		nameStr.setPosition(87, 77);
		
		infoUserFrame.addActor(createImage(ctr.a.onlineGomeMoney, (87), (35),(30), (30)));
		diamond = ((createImage(ctr.a.iconGomeMoney, (87), (57),(38), (41))));
		infoUserFrame.addActor(diamond);
		
		infoUserFrame.addActor(moneyStr);
		infoUserFrame.addActor(nameStr);
		infoUserFrame.addActor(transBut);
		
		infoUserFrame.setPosition(x, y);
		infoUserFrame.setVisible(true);		
		return infoUserFrame;
	}
	
	
	public Table createAvatar(String name, long money, float x, float y, float scale){		
		Table infoUserFrame=null;
		Label moneyStr, nameStr;
		
		infoUserFrame = createTableWithTransBg(ctr.g.mSkin, 0, 0, (244), (99));
			
		infoUserFrame.addActor(createImage(ctr.a.avatarFrame, 0, 0,(244), (99)));
		infoUserFrame.addActor(createImage(ctr.a.avatarBoss, (20), (10),(72), (72)));
		infoUserFrame.addActor(createImage(ctr.a.fbAttackIcon, (70), (10),(28), (28)));
		
		moneyStr = createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0);
		moneyStr.setText(money+"");
		moneyStr.setPosition(135, 47);
		
		nameStr = createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0);
		nameStr.setText(name);
		nameStr.setPosition(102, 77);
		
		
		infoUserFrame.addActor(createImage(ctr.a.iconGomeMoney, (102), (28),(38), (41)));
		
		infoUserFrame.addActor(moneyStr);
		infoUserFrame.addActor(nameStr);
//		
		infoUserFrame.setPosition(x, y);
		return infoUserFrame;
	}
	
	public void createDialog(Stage stage, final TweenManager tweenManager,String stext, int numberButton, final ChangeListener okLis, final ChangeListener noLis){
		ctr.a.isHasDialog.add(1);				
		ctr.d.backLis.removeAllElements();
		final Table dialog = createTable(ctr.g.mSkin, (67), (20), (667), (440));				
		final Table contentTable = createTable(ctr.g.mSkin, 0, 0, 667, 440);		
		Image bg = createImage(ctr.a.loginBgDialog_uof, 0, 0);
		Image dim = createImage(ctr.a.blackRegion, (-67), (-20),(800),(480));
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);		
		bg.setOrigin(dialog.getWidth()/2, dialog.getHeight()/2);		
		bg.setPosition((0), (0));
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setColor(1f, 1f, 1f, 0.2f);
		bg.setScale(0.5f, 0.5f);
				
		dialog.addActor(contentTable);
		final ImageButton ok = createImageButton(ctr.g.mSkin, ctr.a.okNorRegion, ctr.a.okPressRegion, null, 0, 0,145,43);
		ImageButton no = createImageButton(ctr.g.mSkin, ctr.a.noNorRegion, ctr.a.noPressRegion, null, 0, 0,145,43);
		
		if(numberButton==1){						
			ok.setPosition((260), (440-348));
			contentTable.addActor(ok);			
		}
		else{			
			ok.setPosition((150), (440-348));
			contentTable.addActor(ok);
			no.setPosition((370), (440-348));
			contentTable.addActor(no);
		}

		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
				if(okLis!=null){					
					okLis.changed(event, actor);
				}
			}
		};
						
		ChangeListener noLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();
				if(noLis!=null){
					noLis.changed(event, actor);
			}
		}
		};
				
		Vector<String> content = cutString2(ctr.g.mFont, stext, (400), 1f);
		float yStart = 410-(440 - content.size()*ctr.g.mFont.getLineHeight())/2;
		float xTemp;
		for(int i = 0;i<content.size();i++){
			Label text = createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0);
			text.setText(content.elementAt(i));
			xTemp = ((667)-text.getTextBounds().width)/2;
			text.setPosition(xTemp, (yStart)-i*ctr.g.mFont.getLineHeight());
			contentTable.addActor(text);
		}
		contentTable.setVisible(false);
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {
			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				contentTable.setVisible(true);
				contentTable.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(contentTable, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);		
		ok.addListener(okLis1);
		no.addListener(noLis1);
	}
	
	public void createDialogErrorLogin(Stage stage, final TweenManager tweenManager,String stext, int numberButton, final ChangeListener okLis){
		ctr.a.isHasDialog.add(1);				
		ctr.d.backLis.removeAllElements();
		final Table dialog = createTable(ctr.g.mSkin, (67), (20), (667), (440));				
		final Table contentTable = createTable(ctr.g.mSkin, 0, 0, 667, 440);		
		Image bg = createImage(ctr.a.loginBgDialog_uof, 0, 0);
		Image dim = createImage(ctr.a.blackRegion, (-67), (-20),(800),(480));
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);		
		bg.setOrigin(dialog.getWidth()/2, dialog.getHeight()/2);		
		bg.setPosition((0), (0));
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setColor(1f, 1f, 1f, 0.2f);
		bg.setScale(0.5f, 0.5f);
				
		dialog.addActor(contentTable);
		final ImageButton ok = createImageButton(ctr.g.mSkin, ctr.a.okNorRegion, ctr.a.okPressRegion, null, 0, 0,145,43);
		ImageButton no = createImageButton(ctr.g.mSkin, ctr.a.resetPass, ctr.a.resetPass2, null, 0, 0,145,43);
		
		if(numberButton==1){						
			ok.setPosition((260), (440-348));
			contentTable.addActor(ok);			
		}
		else{			
			ok.setPosition((150), (440-348));
			contentTable.addActor(ok);
			no.setPosition((370), (440-348));
			contentTable.addActor(no);
		}

		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
				if(okLis!=null){					
					okLis.changed(event, actor);
				}
			}
		};
						
		ChangeListener noLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();
				ctr.androidHelper.openlink(LINK_RESET);
			}		
		};
				
		Vector<String> content = cutString2(ctr.g.mFont, stext, (400), 1f);
		float yStart = 410-(440 - content.size()*ctr.g.mFont.getLineHeight())/2;
		float xTemp;
		for(int i = 0;i<content.size();i++){
			Label text = createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0);
			text.setText(content.elementAt(i));
			xTemp = ((667)-text.getTextBounds().width)/2;
			text.setPosition(xTemp, (yStart)-i*ctr.g.mFont.getLineHeight());
			contentTable.addActor(text);
		}
		contentTable.setVisible(false);
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {
			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				contentTable.setVisible(true);
				contentTable.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(contentTable, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);		
		ok.addListener(okLis1);
		no.addListener(noLis1);
	}
	
	public Table dialogOutVS;
	
	public void createDialogOutVS(Stage stage, final TweenManager tweenManager,String stext, int numberButton, final ChangeListener okLis, final ChangeListener noLis){
		ctr.a.isHasDialog.add(1);				
		ctr.d.backLis.removeAllElements();
		final Table dialog = createTable(ctr.g.mSkin, (67), (20), (667), (440));				
		final Table contentTable = createTable(ctr.g.mSkin, 0, 0, 667, 440);		
		Image bg = createImage(ctr.a.loginBgDialog_uof, 0, 0);
		Image dim = createImage(ctr.a.blackRegion, (-67), (-20),(800),(480));
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);		
		bg.setOrigin(dialog.getWidth()/2, dialog.getHeight()/2);		
		bg.setPosition((0), (0));
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setColor(1f, 1f, 1f, 0.2f);
		bg.setScale(0.5f, 0.5f);
				
		dialog.addActor(contentTable);
		final ImageButton ok = createImageButton(ctr.g.mSkin, ctr.a.okNorRegion, ctr.a.okPressRegion, null, 0, 0,145,43);
		ImageButton no = createImageButton(ctr.g.mSkin, ctr.a.noNorRegion, ctr.a.noPressRegion, null, 0, 0,145,43);
		
		if(numberButton==1){						
			ok.setPosition((260), (440-348));
			contentTable.addActor(ok);			
		}
		else{			
			ok.setPosition((150), (440-348));
			contentTable.addActor(ok);
			no.setPosition((370), (440-348));
			contentTable.addActor(no);
		}

		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
				if(okLis!=null){					
					okLis.changed(event, actor);
				}
			}
		};
						
		ChangeListener noLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();
				if(noLis!=null){
					noLis.changed(event, actor);
			}
		}
		};
				
		Vector<String> content = cutString2(ctr.g.mFont, stext, (400), 1f);
		float yStart = 410-(440 - content.size()*ctr.g.mFont.getLineHeight())/2;
		float xTemp;
		for(int i = 0;i<content.size();i++){
			Label text = createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0);
			text.setText(content.elementAt(i));
			xTemp = ((667)-text.getTextBounds().width)/2;
			text.setPosition(xTemp, (yStart)-i*ctr.g.mFont.getLineHeight());
			contentTable.addActor(text);
		}
		contentTable.setVisible(false);
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {
			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				contentTable.setVisible(true);
				contentTable.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(contentTable, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);		
		ok.addListener(okLis1);
		no.addListener(noLis1);
		
		dialogOutVS = dialog;
	}
	
	public void createDialogExit(Stage stage, final TweenManager tweenManager,String stext, int numberButton, final ChangeListener okLis, final ChangeListener noLis){
		ctr.a.isHasDialog.add(1);				
		ctr.d.backLis.removeAllElements();
		final Table dialog = createTable(ctr.g.mSkin, (67), (20), (667), (440));				
		final Table contentTable = createTable(ctr.g.mSkin, 0, 0, 667, 440);		
		Image bg = createImage(ctr.a.loginBgDialog_uof, 0, 0);
		Image dim = createImage(ctr.a.blackRegion, (-67), (-20),(800),(480));
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);		
		bg.setOrigin(dialog.getWidth()/2, dialog.getHeight()/2);		
		bg.setPosition((0), (0));
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setColor(1f, 1f, 1f, 0.2f);
		bg.setScale(0.5f, 0.5f);
				
		dialog.addActor(contentTable);
		final ImageButton ok = createImageButton(ctr.g.mSkin, ctr.a.okNorRegion, ctr.a.okPressRegion, null, 0, 0,145,43);
		ImageButton no = createImageButton(ctr.g.mSkin, ctr.a.noNorRegion, ctr.a.noPressRegion, null, 0, 0,145,43);
		
		if(numberButton==1){						
			ok.setPosition((260), (440-348));
			contentTable.addActor(ok);			
		}
		else{			
			ok.setPosition((150), (440-348));
			contentTable.addActor(ok);
			no.setPosition((370), (440-348));
			contentTable.addActor(no);
		}

		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				//dialog.remove();
				if(okLis!=null){					
					okLis.changed(event, actor);
				}
			}
		};
						
		ChangeListener noLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();
				if(noLis!=null){
					noLis.changed(event, actor);
			}
		}
		};
				
		Vector<String> content = cutString2(ctr.g.mFont, stext, (400), 1f);
		float yStart = 410-(440 - content.size()*ctr.g.mFont.getLineHeight())/2;
		float xTemp;
		for(int i = 0;i<content.size();i++){
			Label text = createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0);
			text.setText(content.elementAt(i));
			xTemp = ((667)-text.getTextBounds().width)/2;
			text.setPosition(xTemp, (yStart)-i*ctr.g.mFont.getLineHeight());
			contentTable.addActor(text);
		}
		contentTable.setVisible(false);
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {
			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				contentTable.setVisible(true);
				contentTable.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(contentTable, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);		
		ok.addListener(okLis1);
		no.addListener(noLis1);
	}
	
	public void createDialogMoneyCommond(Stage stage, TweenManager tweenManager){
		if(ctr.d.isGoogleVersion)
			createDialogMoneyGP(stage, tweenManager);
		else
			createDialogApotta(stage, tweenManager);
	}
	
	public void createDialogBet(final VSScreen screen, final Stage stage,final TweenManager tweenManager,final IMAction action){		

		ctr.a.isHasDialog.add(1);
		ctr.d.backLis.removeAllElements();
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (500), (359));	
		final Table content = createTable(ctr.g.mSkin, (0), (0), (500), (359));
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 0);
		bg.setSize(500, 345);
		bg.setPosition((0), (15));
		bg.setOrigin(500/2, 345/2);
		bg.setScale(0);
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setScale(0.5f, 0.5f);
		dialog.addActor(content);                                                       
		dialog.setPosition(296, 30);
		
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 500-48, 359-40);	
		
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {	
				if(ctr.a.isHasDialog.size() > 1 || ctr.a.isFbAction)
					return;
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
				action.action();
			}
		};
		
		//close.addListener(closeLis1);
		
		final Vector<Integer> data = new Vector<Integer>();
		
		final ImageButton label = createImageButton(ctr.g.mSkin, ctr.a.textBet,null,null, 0, 330);
		
		label.addListener(new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {	
				if(ctr.a.isHasDialog.size() > 1 || ctr.a.isFbAction)
					return;
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
				action.action();
				if(data.size()==2){
					ctr.d.typeBet = data.elementAt(0);
					ctr.d.betNum = data.elementAt(1);
					//Log.e("HIXHIX",ctr.d.typeBet +"____"+ctr.d.betNum);
					screen.setBetUi();
				}
				else{
					ctr.d.typeBet = 1;
					ctr.d.betNum = 500;
					//Log.e("HIXHIX",ctr.d.typeBet +"____"+ctr.d.betNum);
					screen.setBetUi();
				}
			}
		});
		
		Table table = createTableWithTransBg(ctr.g.mSkin, 0, 0, 500, 250);
		ScrollPane scroll = new ScrollPane(table);
		scroll.setBounds(0, 30, 500, 200);
		
		//createImageButton(ctr.g.mSkin, ctr.a.bgItemBet, null, null, 50, 250-50);
		final CheckBox ok = createCheckBox(ctr.g.mFont, ctr.a.bgItemBet, ctr.a.bgItemBetPress);
		ok.setPosition(15, 250-50);
		ok.addActor(createImage(ctr.a.iconGomeMoney, 40, 0));
		ok.addActor(createLabel(ctr.g.mFont, "500", Color.WHITE, 80, 5));
		
		// createImageButton(ctr.g.mSkin, ctr.a.bgItemBet, null, null, 50, 250-(50+50/3)-50)		
		final CheckBox no = createCheckBox(ctr.g.mFont, ctr.a.bgItemBet, ctr.a.bgItemBetPress);
		no.setPosition(15, 250-(50+50/3)-50);
		no.addActor(createImage(ctr.a.iconGomeMoney, 40, 0));
		no.addActor(createLabel(ctr.g.mFont, "1000", Color.WHITE, 80, 5));
		
		final CheckBox no1 = createCheckBox(ctr.g.mFont, ctr.a.bgItemBet, ctr.a.bgItemBetPress);
		no1.setPosition(15, 250-(50+50/3)*2-50);
		no1.addActor(createImage(ctr.a.iconGomeMoney, 40, 0));
		no1.addActor(createLabel(ctr.g.mFont, "1500", Color.WHITE, 80, 5));
		
		final CheckBox no2 = createCheckBox(ctr.g.mFont, ctr.a.bgItemBet, ctr.a.bgItemBetPress);
		no2.setPosition(15, 250-(50+50/3)*3-50);
		no2.addActor(createImage(ctr.a.iconGomeMoney, 40, 0));
		no2.addActor(createLabel(ctr.g.mFont, "2000", Color.WHITE, 80, 5));
		
		final Image trade1 = createImage(ctr.a.sameRegion, 225, 250-50-5);
		final Image trade2 = createImage(ctr.a.sameRegion, 225, 250-(50+50/3)-50-5);
		final Image trade3 = createImage(ctr.a.sameRegion, 225, 250-(50+50/3)*2-50-5);
		final Image trade4 = createImage(ctr.a.sameRegion, 225, 250-(50+50/3)*3-50-5);
		
		final CheckBox ok21 = createCheckBox(ctr.g.mFont, ctr.a.bgItemBet, ctr.a.bgItemBetPress);
		ok21.setPosition(622-190-135, 250-50);
		ok21.addActor(createImage(ctr.a.onlineGomeMoney, 40, 5));
		ok21.addActor(createLabel(ctr.g.mFont, "2000", Color.WHITE, 85, 5));
		
		final CheckBox no21 = createCheckBox(ctr.g.mFont, ctr.a.bgItemBet, ctr.a.bgItemBetPress);
		no21.setPosition(622-190-135, 250-(50+50/3)-50);
		no21.addActor(createImage(ctr.a.onlineGomeMoney, 40, 5));
		no21.addActor(createLabel(ctr.g.mFont, "4000", Color.WHITE, 85, 5));
		
		final CheckBox no22 = createCheckBox(ctr.g.mFont, ctr.a.bgItemBet, ctr.a.bgItemBetPress);
		no22.setPosition(622-190-135, 250-(50+50/3)*2-50);
		no22.addActor(createImage(ctr.a.onlineGomeMoney, 40, 5));
		no22.addActor(createLabel(ctr.g.mFont, "6000", Color.WHITE, 85, 5));
		
		final CheckBox no23 = createCheckBox(ctr.g.mFont, ctr.a.bgItemBet, ctr.a.bgItemBetPress);
		no23.setPosition(622-190-135, 250-(50+50/3)*3-50);
		no23.addActor(createImage(ctr.a.onlineGomeMoney, 40, 5));
		no23.addActor(createLabel(ctr.g.mFont, "8000", Color.WHITE, 85, 5));
		
		ButtonGroup bet = new ButtonGroup();
		bet.add(ok);
		bet.add(no);                                                   
		bet.add(no1);
		bet.add(no2);
		
		bet.add(ok21);
		bet.add(no21);
		bet.add(no22);
		bet.add(no23);
		
		table.addActor(ok);		
		table.addActor(no);
		table.addActor(no1);
		table.addActor(no2);
		
		table.addActor(trade1);
		table.addActor(trade2);
		table.addActor(trade3);
		table.addActor(trade4);
		
		table.addActor(ok21);
		table.addActor(no21);
		table.addActor(no22);
		table.addActor(no23);
			
		content.addActor(scroll);
		
		content.addActor(close);
		
		content.addActor(label);
		
		content.addActor(createImage(ctr.a.balanceRegion, 176, 238));
		content.addActor(createImage(ctr.a.iconBigGomeMoney, 226-200+40, 195+480-432-15+10,85,85));
		content.addActor(createImage(ctr.a.bigDiamond, 505-200+40, 195+480-432,65,65));
		
		label.setVisible(true);
		ok.setVisible(true);
		no.setVisible(true);
		no1.setVisible(true);
		no2.setVisible(true);
		
		ok21.setVisible(true);
		no21.setVisible(true);
		no22.setVisible(true);
		no23.setVisible(true);
		
		
		
		content.setColor(1f, 1f, 1f, 0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);	
		
		
		
		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {		
				if(ctr.a.isHasDialog.size() > 1 || ctr.a.isFbAction || ok.isChecked() == false)
					return;
				if(ctr.d.moneyOnline<500){
					ctr.androidHelper.showToast(ctr.lang.getNotEnoughMoney(0, 500));
					createDialogMoney(screen, stage, tweenManager);
					return;
				}
				ctr.a.yesSound.play(ctr.a.vls);				
				data.removeAllElements();
				data.add(1);
				data.add(500);
			}
		};
						
		ChangeListener noLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {	
				if(ctr.a.isHasDialog.size() > 1|| ctr.a.isFbAction || no.isChecked() == false)
					return;
				
				if(ctr.d.moneyOnline<1000){
					ctr.androidHelper.showToast(ctr.lang.getNotEnoughMoney(0, 1000));
					createDialogMoney(screen, stage, tweenManager);
					return;
				}
				ctr.a.noSound.play(ctr.a.vls);
				data.removeAllElements();
				data.add(1);
				data.add(1000);
			}		
		};
		ChangeListener noLis2 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {	
				if(ctr.a.isHasDialog.size() > 1 || ctr.a.isFbAction || no1.isChecked() == false)
					return;
				if(ctr.d.moneyOnline<1500){
					ctr.androidHelper.showToast(ctr.lang.getNotEnoughMoney(0, 1500));
					createDialogMoney(screen, stage, tweenManager);
					return;
				}
				ctr.a.noSound.play(ctr.a.vls);
				data.removeAllElements();
				data.add(1);
				data.add(1500);
			}		
		};
		ChangeListener noLis3 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {
				if(ctr.a.isHasDialog.size() > 1 || ctr.a.isFbAction || no2.isChecked() == false)
					return;
				if(ctr.d.moneyOnline<2000){
					ctr.androidHelper.showToast(ctr.lang.getNotEnoughMoney(0, 2000));
					createDialogMoney(screen, stage, tweenManager);
					return;
				}
				ctr.a.noSound.play(ctr.a.vls);
				data.removeAllElements();
				data.add(1);
				data.add(2000);
			}		
		};
		ok.addListener(okLis1);
		no.addListener(noLis1);
		no1.addListener(noLis2);	
		no2.addListener(noLis3);
		
		ChangeListener okLis21 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {	
				if(ctr.a.isHasDialog.size() > 1 || ctr.a.isFbAction || ok21.isChecked() == false)
					return;
				if(ctr.d.money<2000){
					ctr.androidHelper.showToast(ctr.lang.getNotEnoughMoney(1, 2000));
					createDialogMoney(screen, stage, tweenManager);
					return;
				}
				ctr.a.noSound.play(ctr.a.vls);
				data.removeAllElements();
				data.add(2);
				data.add(2000);
			}		
		};
		ChangeListener noLis21 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {	
				if(ctr.a.isHasDialog.size() > 1 || ctr.a.isFbAction || no21.isChecked() == false)
					return;
				if(ctr.d.money<4000){
					ctr.androidHelper.showToast(ctr.lang.getNotEnoughMoney(1, 4000));
					createDialogMoney(screen, stage, tweenManager);
					return;
				}
				ctr.a.noSound.play(ctr.a.vls);
				data.removeAllElements();
				data.add(2);
				data.add(4000);
			}		
		};
		ChangeListener noLis22 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {		
				if(ctr.a.isHasDialog.size() > 1 || ctr.a.isFbAction || no22.isChecked() == false)
					return;
				if(ctr.d.money<6000){
					ctr.androidHelper.showToast(ctr.lang.getNotEnoughMoney(1, 6000));
					createDialogMoney(screen, stage, tweenManager);
					return;
				}
				ctr.a.noSound.play(ctr.a.vls);
				data.removeAllElements();
				data.add(2);
				data.add(6000);
			}		
		};
		ChangeListener noLis23 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {	
				if(ctr.a.isHasDialog.size() > 1 || ctr.a.isFbAction || no23.isChecked() == false)
					return;
				if(ctr.d.money<8000){
					ctr.androidHelper.showToast(ctr.lang.getNotEnoughMoney(1, 8000));
					createDialogMoney(screen, stage, tweenManager);
					return;
				}
				ctr.a.noSound.play(ctr.a.vls);
				data.removeAllElements();
				data.add(2);
				data.add(8000);
			}		
		};
		
		ok21.addListener(okLis21);
		no21.addListener(noLis21);
		no22.addListener(noLis22);
		no23.addListener(noLis23);
		
		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1, null);
		ctr.d.backLis.add(backLis);
	}
	
	public void createDialogTopPlayer(final BaseGameScreen screen, final JSONArray users, final Stage stage,final TweenManager tweenManager){		
		ctr.d.isLoadingLazy = false;
		ctr.d.lazyLoad.removeAllElements();
		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		
		final LazyLoadImage[] lazys = new LazyLoadImage[users.length()];
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (520), (480));	
		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (520), (480));
				
		
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 0);
		bg.setSize(520, 480);
		bg.setPosition((0), (0));
		bg.setOrigin(520/2, 480/2);
		bg.setScale(0);
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setScale(0.5f, 0.5f);
		dialog.addActor(content);
		dialog.setPosition(140, 0);
		
		
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 520-30, 480-50);	
				
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();		
				ctr.d.isLoadingLazy = false;
				ctr.d.lazyLoad.removeAllElements();
				if(lazys!=null){
				for(int i = 0;i<lazys.length;i++){
					if(lazys[i]!=null)
						lazys[i].unload();
				}
				}
			}
		};
		
		Table table = createTableWithTransBg(ctr.g.mSkin, 0, 0, 520, 0);
		
		ScrollPane scroll = new ScrollPane(table);
		scroll.setBounds(0, 30, 520, 340);
		scroll.setScrollingDisabled(true, false);
		table.defaults().expandX().space(50).expandY().space(40);
		String achi=null,name = null,link=null;
		
		 for(int i=0; i<users.length(); i++){
			 JSONObject ele = null;
			try {
				ele = users.getJSONObject(i);
			} catch (JSONException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}	
			 int star = 0;
			 int exp = 0;
			 String ava = null;
			 try{
			 name = ele.getString("user_name");	
			 achi = ele.getString("achievement");
			 star = ele.getInt("star");
			 exp = ele.getInt("experiment");
			 link = ele.getString("sys_avatar");
			 ava = ele.getString("avatar");
			 }
			 catch(Exception ex){				 
			 }
			 boolean isReal = false;
			 Table item;
			 int x = 10;
			 item = createTableWithTransBg(ctr.g.mSkin, x, 0, 390, 120);			 
			 Image bgr = createImage(ctr.a.bgAchieve, x, 0, 390, 120);
			 bgr.setColor(0.5f,0.5f,0.5f,0.5f);
			 item.addActor(bgr);
			 
			 Image avatar = createImage(ctr.a.avatarDefault, x+10, 10, 100, 100);			 
			 item.addActor(avatar);
			 item.addActor(createImage(ctr.a.boderAvatar, 5+x, 5,110,110));
			 		 
			 item.addActor(createLabel(ctr.g.mFont, name, Color.WHITE, x+120, 90));			 
			 
			 starGen(item, x+120, 0, star, ctr.d.getTypeAchievement(achi), 1, true,achi,exp);
			 //item.addActor(createLabel(ctr.g.mFont, "Level:"+ele.getString("level"), Color.WHITE, 130, 40));	
			 //item.addActor(createLabel(ctr.g.mFont, "Exp:"+ele.getString("experiment"), Color.WHITE, 130, 10));	
			
//			 ctr.androidHelper.log("LOG AVATAR "+link);
			 if(link.equals("null")){
				 link = ava;
				 isReal = true;
				 //ctr.androidHelper.log("VAO DAY RUI");				 
			}
			 if(isReal == false && ctr.androidHelper.checkFileExist("/sdcard/data/avatar/"+name)){
				 lazys[i] = new LazyLoadImage(avatar, link, name);				 
//				 final int j = i;
//				 screen.postRunnable(new Runnable() {
//					
//					@Override
//					public void run() {
//						// TODO Auto-generated method stub
						lazys[i].load(screen.getTween());
//					}
//				});
				 lazys[i].load(screen.getTween());
				 ctr.androidHelper.log(name+" KO PHAI LOAD");
			 }			 
			 else
			 {
				
					 lazys[i] = new LazyLoadImage(avatar, link, name);		
					 if(!link.equals("null")){
					 ctr.d.lazyLoad.add(lazys[i]);
				 }
			 }
			 Label number = createLabel(ctr.g.mFontAbc, (i+1)+"", Color.WHITE, 0, 0);
			 number.setX(-number.getTextBounds().width);
			 item.addActor(number);
			 table.add(item);
			 table.row();
			 //log(ele.getString("stt")+"-"+ele.getString("user_id")+"-"+ele.getString("user_name")+"-"+ele.getString("level")+"-"+ele.getString("experiment"));
		 }
		content.addActor(scroll);
		
		content.addActor(close);
				
		
		content.setColor(1f, 1f, 1f, 0f);
		content.addActor(createImage(ctr.a.topText, 115, 400));
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);	
		
		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1, null);
		ctr.d.backLis.add(backLis);
	}
	
	public void createDialogHelpLaw(final Stage stage,final TweenManager tweenManager){

		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		
		Label time, help, swap, search, lawStr;
	
		time = createLabel(ctr.g.mFont, ctr.lang.time, Color.WHITE, 120, 480-140);
		help = createLabel(ctr.g.mFont, ctr.lang.help, Color.WHITE, 120, 480-199);
		swap = createLabel(ctr.g.mFont, ctr.lang.swap, Color.WHITE, 120, 480-379);
		search = createLabel(ctr.g.mFont, ctr.lang.search, Color.WHITE, 120, 480-275);
		lawStr = createLabel(ctr.g.mFont, ctr.lang.lawText, Color.WHITE, 111, 15);
		
		TextureRegion law, back;
		final Texture lawT = new Texture("data/help/help.png");
		lawT.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		final Texture backT = new Texture("data/help/button_back.png");
		backT.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		law = new TextureRegion(lawT);
		back = new TextureRegion(backT);
				
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (800), (480));	
		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (800), (480));
		
		stage.addActor(dialog);
		dialog.addActor(content);
		dialog.setPosition(0, 0);
		
		final ImageButton close = createImageButton(ctr.g.mSkin, back, null, null, 10, 480-10-72);	
		content.addActor(createImage(law, 0, 0));
		content.addActor(close);
		content.addActor(time);
		content.addActor(help);
		content.addActor(swap);
		content.addActor(search);
		content.addActor(lawStr);
		
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();		
				
				if(lawT!=null)
					lawT.dispose();
				if(backT!=null)
					backT.dispose();
				
			}
		};
		
		content.setColor(1f, 1f, 1f, 0f);
	
		Tween.to(content, WidgetAccessor.OPACITY, 1f).target(1).ease(Quad.OUT).start(tweenManager);
		
		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1,null);
		ctr.d.backLis.add(backLis);
	}
	
	public void createDialogHelpML(final Stage stage,final TweenManager tweenManager){		
		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (480), (480));			
		final Table content = createTable(ctr.g.mSkin, (0), (0), (480), (480));
		
		Image dim = createImage(ctr.a.blackRegion, (-160), (0),(800),(480));		
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);
		
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 0);
		bg.setSize(480, 480);
		bg.setPosition((0), (0));
		bg.setOrigin(480/2, 480/2);
		bg.setScale(0);
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setScale(0.5f, 0.5f);
		dialog.addActor(content);
		dialog.setPosition(160, 0);
		
		
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 480-40, 480-50);	
				
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();		
			}
		};
		
		Table table = createTableWithTransBg(ctr.g.mSkin, 0, 0, 400, 0);
		ScrollPane scroll = new ScrollPane(table);
		scroll.setBounds(40, 40, 400, 400);
		scroll.setScrollingDisabled(true, false);
		table.defaults().expandX().space(50).expandY().space(20);
				
		 for(int i=0; i<5; i++){
			 if(i == 3)
				 continue;
			 Table item;
			 ChangeListener lis;
			 final int j = i;
			 lis = new ChangeListener() {
				@Override
				public void changed(ChangeEvent arg0, Actor arg1) {
					// TODO Auto-generated method stub					
					//ctr.a.isHasDialog.removeElementAt(0);
					//ctr.a.yesSound.play(ctr.a.vls);
					//dialog.remove();	
					if( j == 0){						
						createDialogHelpLaw(stage, tweenManager);
					}
					else if( j == 1){						
						createDialogHelpTypeMoney(stage, tweenManager);
					}
					else if( j == 2){						
						createDialogHelpAchieve(stage, tweenManager);
					}
					else if( j == 3){						
						createDialogHowMoney(stage, tweenManager);
					}
					else if( j == 4){						
						createDialogHelpFacebook(stage, tweenManager);
					}					
				}
			};
			 item = createTableWithTransBg(ctr.g.mSkin, 0, 0, 400, 100);		
			 Image bg_item = createImage(ctr.a.bgItemHelp,0,0,400, 100);
			 bg_item.setColor(0.5f, 0.5f, 0.5f, 0.5f);
			 ImageButton but = createImageButton(ctr.g.mSkin, ctr.a.transRegion, ctr.a.transRegion, null, 0, 0, 400, 100);
			 but.addListener(lis);
			 item.addActor(bg_item);
			 item.addActor(but);
			 //item.addActor(createImage(ctr.a.avatarMe, 0, 0, 100, 100));
			 String s;
			 if(i ==0){
				 s = ctr.lang.howToPlay;
			 }
			 else if( i ==1 ){
				 s = ctr.lang.typesMoney;
			 }
			 else if( i ==2 ){
				 s = ctr.lang.achievement;
			 }
			 else if( i ==3 ){
				 s = "Cách nạp tiền?";
			 }
			 else{
				 s = "Facebook?";
			 }
			 but.addActor(createLabel(ctr.g.mFont,s, Color.WHITE, 20, 40));			 
			 table.add(item);
			 table.row();
			 //log(ele.getString("stt")+"-"+ele.getString("user_id")+"-"+ele.getString("user_name")+"-"+ele.getString("level")+"-"+ele.getString("experiment"));
		 }
		
		content.addActor(scroll);		
		content.addActor(close);						
		content.setColor(1f, 1f, 1f, 0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);	
		
		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1,null);
		ctr.d.backLis.add(backLis);
	}
	
	
	public void createDialogTask(final BaseGameScreen screen, final Stage stage,final TweenManager tweenManager, final int taskId){		
		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (480), (400));			
		final Table content = createTable(ctr.g.mSkin, (0), (0), (480), (400));
		
		Image dim = createImage(ctr.a.blackRegion, (-160), (-40),(800),(480));		
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);
		
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 0);
		bg.setSize(480, 400);
		bg.setPosition((0), (0));
		bg.setOrigin(480/2, 400/2);
		bg.setScale(0);
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setScale(0.5f, 0.5f);
		dialog.addActor(content);
		dialog.setPosition(160, 40);		
		
		content.addActor(createLabel(ctr.g.mFontAbc, ctr.lang.taskTitle, Color.WHITE, 130, 320));
		
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 480-40, 400-40);	
				
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();		
			}
		};
		
		Table table = createTableWithTransBg(ctr.g.mSkin, 0, 0, 400, 0);		
		ScrollPane scroll = new ScrollPane(table);
		scroll.setBounds(40, 40, 400, 260);
		scroll.setScrollingDisabled(true, false);
		table.defaults().expandX().space(50).expandY().space(20);
				
		 //for(int i=0; i<5; i++){
			 //log(ele.getString("stt")+"-"+ele.getString("user_id")+"-"+ele.getString("user_name")+"-"+ele.getString("level")+"-"+ele.getString("experiment"));
		 //}
		
			 for(int i=0; i<5; i++){
				 if(i==4 || ctr.d.passTask[i])
					 continue;
				 Table item;
				 ChangeListener lis;
				 final int j = i;
				 lis = new ChangeListener() {
					@Override
					public void changed(ChangeEvent arg0, Actor arg1) {
						// TODO Auto-generated method stub					
						ctr.a.isHasDialog.removeElementAt(0);
						ctr.a.yesSound.play(ctr.a.vls);
						dialog.remove();	
						
						if(ctr.a.isFbAction)
							return;
						
						if( j == 0){								
							final String link = MainActivity.isGooglePlay ? GOOGLE_LINK : APPOTA_LINK;
							
							if(ctr.d.isNetworkAvaiable){
							if(ctr.d.isLoginedFB){
								ctr.a.isFbAction = true;
								screen.mAction = IFacebookProcessorListener.FEED;
								screen.mFBBridge.onNewsFeed(screen, link, NAME, CAPTION, DESCRIPTION, URL);	
							
							} else{
								ctr.a.isFbAction = true;
								screen.afterAction = new IMAction() {
									
									@Override
									public void action() {
										// TODO Auto-generated method stub
										ctr.a.isFbAction = true;
										screen.mAction = IFacebookProcessorListener.FEED;
										screen.mFBBridge.onNewsFeed(screen, link, NAME, CAPTION, DESCRIPTION, URL);	
									}
								};
								screen.mAction = IFacebookProcessorListener.LOGIN;
								screen.mFBBridge.onLogin(screen);
							}
							}
						}
						else if( j == 1){	
							if(ctr.d.isLoginedFB){
								if(ctr.d.isNetworkAvaiable){
									ctr.a.isFbAction = true;
									screen.mAction = IFacebookProcessorListener.SEND_REQUEST;
									screen.mFBBridge.onSendRequest(screen, deepLink, message, data, true);					
								}
								}
								else{
									ctr.a.isFbAction = true;
									if(ctr.d.isNetworkAvaiable){						
											screen.afterAction = new IMAction() {
												
												@Override
												public void action() {
													// TODO Auto-generated method stub

												    ctr.a.isFbAction = true;
													screen.mAction = IFacebookProcessorListener.SEND_REQUEST;
													screen.mFBBridge.onSendRequest(screen, deepLink, message, data, true);	
												}
											};
											screen.mAction = IFacebookProcessorListener.LOGIN;
											screen.mFBBridge.onLogin(screen);						
									}
								}
						}
						else if( j == 2){						
						}
						else if( j == 3){						
						}
						else if( j == 4){						
						}					
					}
				};
				 item = createTableWithTransBg(ctr.g.mSkin, 0, 0, 400, 100);		
				 Image img = createImage(ctr.a.bgItemHelp, 0, 0, 400, 100);
				 img.setColor(0.5f,0.5f,0.5f,0.5f);
				 ImageButton but = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 0, 0, 400, 100);				 
				 
				 //but.setColor(0,1,0.8f,1);
				 			
				 item.addActor(img);
		
				 //item.addActor(createImage(ctr.a.avatarMe, 0, 0, 100, 100));
				 String s;
				 
				 if(i == D.TASK_DRAW){
					 s = ctr.lang.taskDraw;
				 }
				 else if( i == D.TASK_FB_FEED ){
					 s = ctr.lang.taskFeed;
				 }
				 else if( i == D.TASK_FB_SHARE ){
					 s = ctr.lang.taskShare;
				 }
				 else if( i == D.TASK_FB_STORY ){
					 s = ctr.lang.taskStory;
				 }
				 else{
					 s = "VS";
				 }
				 
								 				 
				 item.addActor(createLabel(ctr.g.mFont,s, Color.WHITE, 10, 20));			 
				 but.addListener(lis);	
				 item.addActor(but);
				 table.add(item);
				 table.row();
				 //log(ele.getString("stt")+"-"+ele.getString("user_id")+"-"+ele.getString("user_name")+"-"+ele.getString("level")+"-"+ele.getString("experiment"));
			 }
			 
		content.addActor(scroll);		
		content.addActor(close);						
		content.setColor(1f, 1f, 1f, 0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);	
		
		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1,null);
		ctr.d.backLis.add(backLis);
	}
	
	
	public void createDialogHelpTypeMoney(final Stage stage,final TweenManager tweenManager){		
		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (480), (480));			
		final Table content = createTable(ctr.g.mSkin, (0), (0), (480), (480));
		
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 0);
		bg.setSize(480, 480);
		bg.setPosition((0), (0));
		bg.setOrigin(480/2, 480/2);
		bg.setScale(0);
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setScale(0.5f, 0.5f);
		dialog.addActor(content);
		dialog.setPosition(160, 0);
		
		
		
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 480-40, 480-50);	
				
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();		
			}
		};
		
		Table table = createTableWithTransBg(ctr.g.mSkin, 0, 0, 400, 0);
		ScrollPane scroll = new ScrollPane(table);
		scroll.setBounds(40, 40, 400, 400);
		scroll.setScrollingDisabled(true, false);
		table.defaults().expandX().space(50).expandY().space(20);
				
		Image bg1 = createImage(ctr.a.bgItemHelp, 0, 180, 400, 150);
		bg1.setColor(0.5f, 0.5f, 0.5f, 0.5f);
		table.addActor(bg1);
		table.addActor(createLabel(ctr.g.mFontAbc, ctr.lang.titleTypesMoney, Color.WHITE, ctr.d.isVietnamese?45:10, 330+20));
		table.addActor(createImage(ctr.a.iconGomeMoney, 0, 290));
		table.addActor(createLabel(ctr.g.mFont, ctr.lang.content1TypesMoney, Color.WHITE, 5, 180));
		
		
		Image bg2 = createImage(ctr.a.bgItemHelp, 0, 20, 400, 150);
		bg2.setColor(0.5f, 0.5f, 0.5f, 0.5f);
		table.addActor(bg2);
		table.addActor(createImage(ctr.a.onlineGomeMoney, 0, 135));
		table.addActor(createLabel(ctr.g.mFont, ctr.lang.content2TypesMoney, Color.WHITE, 5, 20));
		
		
		content.addActor(scroll);		
		content.addActor(close);						
		content.setColor(1f, 1f, 1f, 0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);	
		
		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1,null);
		ctr.d.backLis.add(backLis);
	}
	
	public void createDialogHelpAchieve(final Stage stage,final TweenManager tweenManager){		

		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (480), (480));			
		final Table content = createTable(ctr.g.mSkin, (0), (0), (480), (480));
		
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 0);
		bg.setSize(480, 480);
		bg.setPosition((0), (0));
		bg.setOrigin(480/2, 480/2);
		bg.setScale(0);
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setScale(0.5f, 0.5f);
		dialog.addActor(content);
		dialog.setPosition(160, 0);
				
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 480-40, 480-50);	
				
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();		
			}
		};
		
		Table table = createTableWithTransBg(ctr.g.mSkin, 0, 0, 400, 0);
		ScrollPane scroll = new ScrollPane(table);
		scroll.setBounds(40, 40, 400, 400);
		scroll.setScrollingDisabled(true, false);
		table.defaults().expandX().space(50).expandY().space(20);
		
		table.add(createLabel(ctr.g.mFontAbc,ctr.lang.titleAchievement, Color.WHITE, 0, 0)).align(Align.center);
		table.row();
		table.add(createLabel(ctr.g.mFont,ctr.lang.noteAchievement, Color.WHITE, 0, 0)).align(Align.center);
		table.row();
		
		for(int i = 4; i>=0; i--){
			table.add(starGenHelp(i));
			table.row();
		}
		
		content.addActor(scroll);		
		content.addActor(close);						
		content.setColor(1f, 1f, 1f, 0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);	
		
		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1,null);
		ctr.d.backLis.add(backLis);
	}
	
	public void createDialogHowMoney(final Stage stage,final TweenManager tweenManager){		

		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (480), (480));			
		final Table content = createTable(ctr.g.mSkin, (0), (0), (480), (480));
		
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 0);
		bg.setSize(480, 480);
		bg.setPosition((0), (0));
		bg.setOrigin(480/2, 480/2);
		bg.setScale(0);
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setScale(0.5f, 0.5f);
		dialog.addActor(content);
		dialog.setPosition(160, 0);
				
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 480-40, 480-50);	
				
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();		
			}
		};
		
		Table table = createTableWithTransBg(ctr.g.mSkin, 40, 100, 400, 400);
//		ScrollPane scroll = new ScrollPane(table);
//		scroll.setBounds(40, 40, 400, 400);
//		scroll.setScrollingDisabled(true, false);
		//table.defaults().expandX().space(50).expandY().space(20);
		
		table.add(createLabel(ctr.g.mFont,"CÁCH NẠP TIỀN", Color.WHITE, 0, 0)).align(Align.center|Align.top);
		table.row();
		table.add(createLabel(ctr.g.mFont,"Click Avatar -> Biểu tượng nạp\n" +
										  "-> Chọn phương thức nạp"
				, Color.WHITE, 0, 0)).align(Align.left|Align.top);
		table.row();
		table.add(createLabel(ctr.g.mFont,"Phương thức qua Facebook bạn\n" +
										  "được cộng tiền kim cương"				
				  , Color.WHITE, 0, 0)).align(Align.left|Align.top);
		table.row();
		table.add(createLabel(ctr.g.mFont,"Phương thức Appota, Coupon bạn\n" +
										  "bạn được cộng tiền Zegome Gold\n"+
										  "và được hưởng khuyến mãi nếu có"
				  , Color.WHITE, 0, 0)).align(Align.left|Align.top);
		table.row();
				
		content.addActor(table);		
		content.addActor(close);						
		content.setColor(1f, 1f, 1f, 0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);	
		
		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1,null);
		ctr.d.backLis.add(backLis);
	}
	
	
	public void createDialogHelpFacebook(final Stage stage,final TweenManager tweenManager){		

		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (480), (480));			
		final Table content = createTable(ctr.g.mSkin, (0), (0), (480), (480));
		
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 0);
		bg.setSize(480, 480);
		bg.setPosition((0), (0));
		bg.setOrigin(480/2, 480/2);
		bg.setScale(0);
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setScale(0.5f, 0.5f);
		dialog.addActor(content);
		dialog.setPosition(160, 0);
				
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 480-40, 480-50);	
				
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();		
			}
		};
		
		Table table = createTableWithTransBg(ctr.g.mSkin, 40, 100, 400, 400);
//		ScrollPane scroll = new ScrollPane(table);
//		scroll.setBounds(40, 40, 400, 400);
//		scroll.setScrollingDisabled(true, false);
		//table.defaults().expandX().space(50).expandY().space(20);
		
		table.add(createLabel(ctr.g.mFontAbc,"Facebook", Color.WHITE, 0, 0)).align(Align.center|Align.top);
		table.row();
		table.add(createLabel(ctr.g.mFont,ctr.lang.content1FB
				, Color.WHITE, 0, 0)).align(Align.left|Align.top);
		table.row();
		table.add(createLabel(ctr.g.mFont,ctr.lang.content2FB			
				  , Color.WHITE, 0, 0)).align(Align.left|Align.top);
		table.row();
		table.add(createLabel(ctr.g.mFont,ctr.lang.content3FB
				  , Color.WHITE, 0, 0)).align(Align.left|Align.top);
		table.row();
				
		content.addActor(table);		
		content.addActor(close);						
		content.setColor(1f, 1f, 1f, 0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);	
		
		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1,null);
		ctr.d.backLis.add(backLis);
	}
	
	
	public void createDialogMoneyGP(final Stage stage,final TweenManager tweenManager){		
		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (617), (361));	
		final Table content = createTable(ctr.g.mSkin, (0), (0), (617), (361));	
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 0);
		bg.setSize(617, 361);
		bg.setPosition((0), (0));
		bg.setOrigin(617/2, 361/2);
		bg.setScale(0);
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setScale(0.5f, 0.5f);
		dialog.setPosition(92, 50);
		dialog.addActor(content);
		
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 617-40, 361-40);		
		final Image label = createImage(ctr.a.gomeShopIcon,120,230);
		
		final ImageButton ok = createImageButton(ctr.g.mSkin, ctr.a.elGPPay, ctr.a.elGPPayPress, null, 40, 140);
		ok.addActor(createImage(ctr.a.oneGomeMoney, 25, 25));
		ok.addActor(createLabel(ctr.g.mFont, "5000", Color.WHITE, 95, 35));
		ok.addActor(createLabel(ctr.g.mFont, "1.99", Color.WHITE, 180, 45));
		ok.addActor(createImage(ctr.a.buyMoney, 249-68, 5));
		final ImageButton no = createImageButton(ctr.g.mSkin, ctr.a.elGPPay, ctr.a.elGPPayPress, null, 320, 140);
		no.addActor(createImage(ctr.a.twoGomeMoney, 18,18));
		no.addActor(createLabel(ctr.g.mFont, "17000", Color.WHITE, 95, 35));
		no.addActor(createLabel(ctr.g.mFont, "4.99", Color.WHITE, 180, 45));
		no.addActor(createImage(ctr.a.buyMoney, 249-68, 5));
		final ImageButton no1 = createImageButton(ctr.g.mSkin, ctr.a.elGPPay, ctr.a.elGPPayPress, null, 40, 40);
		no1.addActor(createImage(ctr.a.threeGomeMoney, 18,15));
		no1.addActor(createLabel(ctr.g.mFont, "40000", Color.WHITE, 95, 35));
		no1.addActor(createLabel(ctr.g.mFont, "9.99", Color.WHITE, 180, 45));
		no1.addActor(createImage(ctr.a.buyMoney, 249-68, 5));
		final ImageButton no2 = createImageButton(ctr.g.mSkin, ctr.a.elGPPay, ctr.a.elGPPayPress, null, 320, 40);
		no2.addActor(createImage(ctr.a.fourGomeMoney, 18,8));
		no2.addActor(createLabel(ctr.g.mFont, "100000", Color.WHITE, 95, 35));
		no2.addActor(createLabel(ctr.g.mFont, "14.99", Color.WHITE, 180, 45));
		no2.addActor(createImage(ctr.a.buyMoney, 249-68, 5));
		
		content.addActor(ok);
		content.addActor(no);
		content.addActor(no1);
		content.addActor(no2);
		content.addActor(label);
		content.addActor(close);
		
//		label.setVisible(false);
//		ok.setVisible(false);
//		no.setVisible(false);
//		no1.setVisible(false);
//		no2.setVisible(false);
//		close.setVisible(false);
		
		content.setColor(1f, 1f, 1f, 0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);	
		
		
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
			}
		};
		
		//close.addListener(closeLis1);
		
		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
			}
		};
						
		ChangeListener noLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();				
			}		
		};
		ChangeListener noLis2 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();
			}		
		};
		
		ChangeListener noLis3 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();
			}		
		};
		
		ok.addListener(okLis1);
		no.addListener(noLis1);
		no1.addListener(noLis2);		
		no2.addListener(noLis3);
		
		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1,null);
		ctr.d.backLis.add(backLis);
	}
	
		
	public void createDialogMoney(final BaseGameScreen screen, final Stage stage,final TweenManager tweenManager){
		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (480), (480));		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (480), (480));	
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 0);
		bg.setSize(480, 480);
		bg.setPosition((0), (0));
		bg.setOrigin(240, 240);
		bg.setScale(0);
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setScale(0.5f, 0.5f);
		dialog.setPosition(160, 0);
		
		dialog.addActor(content);

		
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 440, 480-50);		
		final Image label = createImage(ctr.a.gomeShopIcon,70,265);
		
		//createButtonText("Mời bạn bè Facebook", 40, 250, 400, 55);
		final ImageButton ok =  createImageButton(ctr.g.mSkin, ctr.a.askFBNor, ctr.a.askFBPress, null, 90, 180,300,55);
		//createButtonText("Thanh toán APOTTA", 40, 150, 400, 55);
		final ImageButton no = createImageButton(ctr.g.mSkin, ctr.a.addGoldNor, ctr.a.addGoldPress, null, 90, 100,300,55);
		// createButtonText("Thẻ Coupon", 40, 50, 400, 55);
		final ImageButton no1 = createImageButton(ctr.g.mSkin, ctr.a.cuponNor, ctr.a.cuponPress, null, 90, 20,300,55);
	
		// createButtonText("Thẻ Coupon", 40, 50, 400, 55);
	     final ImageButton no2 = createImageButton(ctr.g.mSkin, ctr.a.shareFb, ctr.a.shareFBPress, null, 90, 260,300,55);

		
		content.addActor(label);
		
		content.addActor(ok);
		content.addActor(no);
		content.addActor(no1);
		content.addActor(no2);
		
		content.addActor(close);
		
//		label.setVisible(false);
//		ok.setVisible(false);
//		no.setVisible(false);
//		no1.setVisible(false);
//		close.setVisible(false);
		
		content.setColor(1f, 1f, 1f, 0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);	
		
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
			}
		};
		
		//close.addListener(closeLis1);
		
		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
				if(ctr.a.isFbAction)
					return;
				if(ctr.d.isLoginedFB){
				if(ctr.d.isNetworkAvaiable){
					ctr.a.isFbAction = true;
					screen.mAction = IFacebookProcessorListener.SEND_REQUEST;
					screen.mFBBridge.onSendRequest(screen, deepLink, message, data, true);					
				}
				}
				else{
					ctr.a.isFbAction = true;
					if(ctr.d.isNetworkAvaiable){						
							screen.afterAction = new IMAction() {
								
								@Override
								public void action() {
									// TODO Auto-generated method stub

								    ctr.a.isFbAction = true;
									screen.mAction = IFacebookProcessorListener.SEND_REQUEST;
									screen.mFBBridge.onSendRequest(screen, deepLink, message, data, true);	
								}
							};
							screen.mAction = IFacebookProcessorListener.LOGIN;
							screen.mFBBridge.onLogin(screen);						
					}
				}
			}
		};
						
		ChangeListener noLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				//ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				//dialog.remove();
				if(ctr.d.isLogined() == false){
				screen.setWaitAction(
						new IMActionBoolean() {
							
							@Override
							public boolean isFinish() {
								// TODO Auto-generated method stub
								return ctr.d.isLogined();
							}
							
							@Override
							public void end() {
								// TODO Auto-generated method stub
								ctr.stageHelper.dimissDialogLoading();
								ctr.androidHelper.sendStartTransaction(stage, tweenManager);
							}
							
							@Override
							public void begin() {
								// TODO Auto-generated method stub		
								ctr.stageHelper.createDialogLoading(stage, tweenManager);
							}
						});
				}
				else
					ctr.androidHelper.sendStartTransaction(stage, tweenManager);
				//createDialogMoneyCommond(stage, tweenManager);
			}		
		};
		ChangeListener noLis2 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();
				if(ctr.d.isLogined() == false){
					screen.setWaitAction(
							new IMActionBoolean() {
								
								@Override
								public boolean isFinish() {
									// TODO Auto-generated method stub
									return ctr.d.isLogined();
								}
								
								@Override
								public void end() {
									// TODO Auto-generated method stub
									ctr.stageHelper.dimissDialogLoading();
									ctr.stageHelper.createDialogCoupon(stage, tweenManager, null);
								}
								
								@Override
								public void begin() {
									// TODO Auto-generated method stub		
									ctr.stageHelper.createDialogLoading(stage, tweenManager);
								}
							});
					}
					else
						createDialogCoupon(stage, tweenManager,null);
			}		
		};
		
		ChangeListener noLis3 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
				
				if(ctr.a.isFbAction)
					return;
				
				final String link = MainActivity.isGooglePlay ? GOOGLE_LINK : APPOTA_LINK;
				
				if(ctr.d.isNetworkAvaiable){
				if(ctr.d.isLoginedFB){
					ctr.a.isFbAction = true;
					screen.mAction = IFacebookProcessorListener.FEED;
					screen.mFBBridge.onNewsFeed(screen, link, NAME, CAPTION, DESCRIPTION, URL);	
				
				} else{
					ctr.a.isFbAction = true;
					screen.afterAction = new IMAction() {
						
						@Override
						public void action() {
							// TODO Auto-generated method stub
							ctr.a.isFbAction = true;
							screen.mAction = IFacebookProcessorListener.FEED;
							screen.mFBBridge.onNewsFeed(screen, link, NAME, CAPTION, DESCRIPTION, URL);	
						}
					};
					screen.mAction = IFacebookProcessorListener.LOGIN;
					screen.mFBBridge.onLogin(screen);
				}
				}
			}
		};
		
		ok.addListener(okLis1);
		no.addListener(noLis1);
		no1.addListener(noLis2);	
		no2.addListener(noLis3);

		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1,null);
		ctr.d.backLis.add(backLis);
	}
	
	public void createDialogShareFB(final BaseGameScreen screen, final Stage stage,final TweenManager tweenManager){
		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (480), (288));		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (480), (288));	
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 0);
		bg.setSize(480, 288);
		bg.setPosition((0), (0));
		bg.setOrigin(240, 144);
		bg.setScale(0);
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setScale(0.5f, 0.5f);
		dialog.setPosition(160,96);
		dialog.addActor(content);
		
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 440, 288-50);			
		//createButtonText("SMS", 40, 250, 400, 55);
		final ImageButton ok =  createImageButton(ctr.g.mSkin, ctr.a.shareFb, ctr.a.shareFBPress, null, 90, 150,300,55);
		// createButtonText("Paypal", 40, 50, 400, 55);
		final ImageButton no2 = createImageButton(ctr.g.mSkin, ctr.a.askFBNor, ctr.a.askFBPress, null, 90, 50,300,55);	
		
		content.addActor(ok);
		content.addActor(no2);
		content.addActor(close);
		
//		label.setVisible(false);
//		ok.setVisible(false);
//		no.setVisible(false);
//		no1.setVisible(false);
//		close.setVisible(false);
		
		content.setColor(1f, 1f, 1f, 0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
				
			}
		})
		.start(tweenManager);	
		
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
			}
		};
		
		//close.addListener(closeLis1);
		
		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
				if(ctr.a.isFbAction)
					return;
				final String link = MainActivity.isGooglePlay ? GOOGLE_LINK : APPOTA_LINK;
				if(ctr.d.isLoginedFB){
					if(ctr.d.isNetworkAvaiable){
						ctr.a.isFbAction = true;
						screen.mAction = IFacebookProcessorListener.SEND_REQUEST;
						screen.mFBBridge.onNewsFeed(screen, link, NAME, CAPTION, DESCRIPTION, URL);						
					}
					}
					else{
						ctr.a.isFbAction = true;
						if(ctr.d.isNetworkAvaiable){						
								screen.afterAction = new IMAction() {
									
									@Override
									public void action() {
										// TODO Auto-generated method stub

									    ctr.a.isFbAction = true;
										screen.mAction = IFacebookProcessorListener.FEED;
										screen.mFBBridge.onNewsFeed(screen, link, NAME, CAPTION, DESCRIPTION, URL);											
									}
								};
								screen.mAction = IFacebookProcessorListener.LOGIN;
								screen.mFBBridge.onLogin(screen);						
						}
					}
			}
		};
							
		ChangeListener noLis3 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();				
				if(ctr.a.isFbAction)
					return;
				if(ctr.d.isLoginedFB){
					if(ctr.d.isNetworkAvaiable){
						ctr.a.isFbAction = true;
						screen.mAction = IFacebookProcessorListener.SEND_REQUEST;
						screen.mFBBridge.onSendRequest(screen, deepLink, message, data, true);					
					}
					}
					else{
						ctr.a.isFbAction = true;
						if(ctr.d.isNetworkAvaiable){						
								screen.afterAction = new IMAction() {
									
									@Override
									public void action() {
										// TODO Auto-generated method stub

									    ctr.a.isFbAction = true;
										screen.mAction = IFacebookProcessorListener.SEND_REQUEST;
										screen.mFBBridge.onSendRequest(screen, deepLink, message, data, true);	
									}
								};
								screen.mAction = IFacebookProcessorListener.LOGIN;
								screen.mFBBridge.onLogin(screen);						
						}
					}
			}		
			
		};
		ok.addListener(okLis1);		
		no2.addListener(noLis3);
		
		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1,null);		
		ctr.d.backLis.add(backLis);
	}
	
	public void createDialogPayGoldDiamond(final BaseGameScreen screen, final Stage stage,final TweenManager tweenManager,final int gold,final int diamond, final IMAction success){
		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (480), (288));		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (480), (288));	
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 0);
		bg.setSize(480, 288);
		bg.setPosition((0), (0));
		bg.setOrigin(240, 144);
		bg.setScale(0);
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setScale(0.5f, 0.5f);
		dialog.setPosition(160,96);
		dialog.addActor(content);
		
		final ImageButton no1 = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 50, 60, 150, 150);
		final Image im1 = createImage(ctr.a.bgAchieve, 0, 0, 150,150);
		im1.setColor(0.5f, 0.5f, 0.5f, 0.5f);
		no1.addActor(im1);
		no1.setDisabled(true);
		no1.addActor(createImage(ctr.a.iconGomeMoney, 25, 50));
		no1.addActor(createLabel(ctr.g.mFont, ""+gold, Color.WHITE, 65, 55));
		content.addActor(no1);
		
		final ImageButton no3 = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 280, 60, 150, 150);
		final Image im2 = createImage(ctr.a.bgAchieve, 0, 0, 150,150);
		im2.setColor(0.5f, 0.5f, 0.5f, 0.5f);
		no3.addActor(im2);
		no3.setDisabled(true);
		no3.addActor(createImage(ctr.a.onlineGomeMoney, 25, 50));
		no3.addActor(createLabel(ctr.g.mFont, ""+diamond, Color.WHITE, 65, 55));
		content.addActor(no3);
		
		
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 440, 288-50);			
		//createButtonText("SMS", 40, 250, 400, 55);
		final ImageButton ok =  createImageButton(ctr.g.mSkin, ctr.a.okNorRegion, ctr.a.okPressRegion, null, 2, -10);
		// createButtonText("Paypal", 40, 50, 400, 55);
		final ImageButton no2 = createImageButton(ctr.g.mSkin, ctr.a.okNorRegion, ctr.a.okPressRegion, null, 2, -10);	
		
		no1.addActor(ok);
		no3.addActor(no2);
		
		content.addActor(close);
		
//		label.setVisible(false);
//		ok.setVisible(false);
//		no.setVisible(false);
//		no1.setVisible(false);
//		close.setVisible(false);
		
		content.setColor(1f, 1f, 1f, 0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
				
			}
		})
		.start(tweenManager);	
		
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
			}
		};
		
		//close.addListener(closeLis1);
		
		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {															
				//=====
				final IMAction action = new IMAction() {
					
					@Override
					public void action() {
						// TODO Auto-generated method stub
						if(ctr.d.moneyOnline>=gold){		
							
							ctr.a.isHasDialog.removeElementAt(0);
							ctr.a.yesSound.play(ctr.a.vls);
							dialog.remove();
							
							ctr.stageHelper.createDialogLoading(stage, tweenManager);
							ctr.androidHelper.sendPayMoneyGome(stage, tweenManager, (-1)*gold, success);
						}
						else{															
							ctr.androidHelper.showToast(ctr.lang.getNotEnoughMoney(0, gold));
							createDialogMoney(screen, stage, tweenManager);
						}
					}
				};
			
				
				if(ctr.d.isNetworkAvaiable == false){
					ctr.stageHelper.createDialog(stage, tweenManager, ctr.lang.turnOnNetworkForTask, 1, null, null);
					return;
				}
				else {
					if(!ctr.d.isLogined() && ctr.d.isHasAccount){		
						screen.setWaitAction(new  IMActionBoolean() {
					
					@Override
					public boolean isFinish() {
						// TODO Auto-generated method stub
						return ctr.d.isLogined();
					}
					
					@Override
					public void end() {
						// TODO Auto-generated method stub
						action.action();
						ctr.stageHelper.dimissDialogLoading();
					}
					
					@Override
					public void begin() {
						// TODO Auto-generated method stub
						ctr.stageHelper.createDialogLoading(stage, tweenManager);
					}
				});
					}
					else if(ctr.d.isHasAccount == false){
						//action.action();
						final IWMAction loginSuccess = new IWMAction() {					
							@Override
							public void action(String result) {						
								try{
								JSONObject jsObj = new JSONObject(result);
								// TODO Auto-generated method stub
								if (result == null) {
									ctr.d.isSendingLogin = false;
								} else {																				
									 if(jsObj.getString("code").equals("1")){
										 
										 ctr.d.name = ctr.d.namePre;
										 ctr.d.email = ctr.d.emailPre;
										 ctr.d.pass = ctr.d.passPre;	
										 
										 JSONObject content = jsObj.getJSONObject("content");
										 								 								 
										 JSONArray messages = content.getJSONArray("message");
										 
										 JSONArray gifts = content.getJSONArray("gift");

										 JSONArray advertise = content.getJSONArray("advertise");
										 
										 try{
										 JSONArray giftsDaily = content.getJSONArray("daily_gift");										
										 for(int i=0; i<giftsDaily.length(); i++){
												 JSONObject ele = giftsDaily.getJSONObject(i);
												 ctr.d.dailyGifts.add(new DailyGift(ele.getInt("zegome_gold"), ele.getString("message")));
											 }
										 }
										 catch(Exception ex){}
										 for(int i=0; i<messages.length(); i++){
											 JSONObject ele = messages.getJSONObject(i);
											 ctr.autoRunText.addNotify(0,ctr.d.isVietnamese?ele.getString("message_content"):ele.getString("message_eng"),null,null);
										 }
										 
										 for(int i=0; i<advertise.length(); i++){
											 JSONObject ele = advertise.getJSONObject(i);
											 //ctr.a.notify.add(ele.getString("gift_id") +"-"+ele.getString("user_send")+"-"+ele.getString("zegome_gold")+"-"+ele.getString("coupon")+"-"+ele.getString("message"));
											 ctr.d.gameAdvertiseLoad.add(i,new GameAdvertise(i,ele.getString("icon"), ele.getString("link"), ctr.d.isVietnamese?ele.getString("message_vn"):ele.getString("message_eng")));
										 }
										 
										 for(int i=0; i<gifts.length(); i++){
											 JSONObject ele = gifts.getJSONObject(i);
											 //ctr.a.notify.add(ele.getString("gift_id") +"-"+ele.getString("user_send")+"-"+ele.getString("zegome_gold")+"-"+ele.getString("coupon")+"-"+ele.getString("message"));
											 ctr.d.gifts.add(new Gift(ele.getInt("gift_id"), ele.getString("user_send"), ele.getInt("zegome_gold"), ele.getString("coupon"), ele.getString("message")));
										 }
										 								
										 								 
										 ctr.d.moneyOnline = content.getInt("user_gome");
										 ctr.d.level = content.getInt("level");
										 ctr.d.total_win = content.getInt("total_win");
										 ctr.d.total_lose = content.getInt("total_lose");
										 ctr.d.achievement = content.getString("achievement");
										 ctr.d.exp = content.getInt("experiment");
										 ctr.d.star = content.getInt("star");
										 ctr.d.isHasAccount = true;
										 ctr.d.saveAccount();						
										 ctr.d.isLogined = true;
										 ctr.d.isSendingLogin = false;								 								 
										 ctr.stageHelper.dimissDialogLoading();
									 }
									 else {
										 screen.logout();
										 ctr.stageHelper.createDialogErrorLogin(stage, tweenManager, ctr.lang.error+": "+jsObj.getString("content"), 2, null);
										 ctr.d.isSendingLogin = false;
									 }
									 
								}
							}
								catch(Exception ex){
									ctr.androidHelper.log(ex.getMessage());
								}
							}
						};				
						ctr.stageHelper.createDialogLogin(stage, tweenManager, "", "", loginSuccess, null, null, null);
					}
					else{
						action.action();
					}
				}

				//=====
			}
		};
							
		ChangeListener noLis3 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {											
				//====
				if(ctr.d.money<diamond){
					ctr.androidHelper.showToast(ctr.lang.getNotEnoughMoney(1, diamond));
					createDialogMoney(screen, stage, tweenManager);
				}
				else{									
					ctr.a.isHasDialog.removeElementAt(0);
					ctr.a.yesSound.play(ctr.a.vls);
					dialog.remove();
					ctr.d.money -= diamond;
					ctr.d.saveAccount();
					success.action();
				}
				//====
			}		
		};
		ok.addListener(okLis1);		
		no2.addListener(noLis3);
		
		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1,null);		
		ctr.d.backLis.add(backLis);
	}
	
	public void createDialogApotta(final Stage stage,final TweenManager tweenManager){
		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (480), (480));		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (480), (480));	
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 0);
		bg.setSize(480, 480);
		bg.setPosition((0), (0));
		bg.setOrigin(240, 240);
		bg.setScale(0);
		dialog.addActor(bg);
		stage.addActor(dialog);
		bg.setScale(0.5f, 0.5f);
		dialog.setPosition(160, 0);
		dialog.addActor(content);
		
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 440, 480-50);			
		//createButtonText("SMS", 40, 250, 400, 55);
		final ImageButton ok =  createImageButton(ctr.g.mSkin, ctr.a.sms, ctr.a.smsPress, null, 90, 250,300,55);
		//createButtonText("The cao", 40, 150, 400, 55);
		final ImageButton no = createImageButton(ctr.g.mSkin, ctr.a.scratch, ctr.a.scratchPress, null, 90, 150,300,55);
		// createButtonText("Bank", 40, 50, 400, 55);
		final ImageButton no1 = createImageButton(ctr.g.mSkin, ctr.a.bank, ctr.a.bankPress, null, 90, 50,300,55);
		// createButtonText("Paypal", 40, 50, 400, 55);
		final ImageButton no2 = createImageButton(ctr.g.mSkin, ctr.a.paypal, ctr.a.paypalPress, null, 90, 350,300,55);	
		
		content.addActor(ok);
		content.addActor(no);
		content.addActor(no1);
		content.addActor(no2);
		content.addActor(close);
		
//		label.setVisible(false);
//		ok.setVisible(false);
//		no.setVisible(false);
//		no1.setVisible(false);
//		close.setVisible(false);
		
		content.setColor(1f, 1f, 1f, 0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
				
			}
		})
		.start(tweenManager);	
		
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
			}
		};
		
		//close.addListener(closeLis1);
		
		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
//				if(true){
//					ctr.androidHelper.sendFinishTransaction(stage, tweenManager, "15000","VND");
//					return;
//				}
				createDialog(stage, tweenManager, ctr.lang.smsFee, 2,new ChangeListener() {
					
					@Override
					public void changed(ChangeEvent arg0, Actor arg1) {
						// TODO Auto-generated method stub
						ctr.controller.callSmsPurchase(new ISmsProcessor() {
							
							@Override
							public void onSmsAutoSuccess() {
								// TODO Auto-generated method stub
								
							}
							
							@Override
							public void onSmsAutoError() {
								// TODO Auto-generated method stub
								
							}
							
							@Override
							public void onSendSMSSuccess() {
								// TODO Auto-generated method stub
								ctr.androidHelper.sendFinishTransaction(stage, tweenManager, "15000","VND");
							}
							
							@Override
							public void onSendSMSFailure() {
								// TODO Auto-generated method stub
								ctr.androidHelper.showToast(ctr.lang.sendSMSFailure);
							}
						});
					}
				}, null);
			}
		};
						
		ChangeListener noLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();				
				ctr.controller.callCardPurchase(new IAppotaPaymentProcessorListener() {
					@Override
					public void onTransactionSuccess(String arg0, String arg1, String arg2,
							int arg3) {
						// TODO Auto-generated method stub						
						ctr.androidHelper.sendFinishTransaction(stage, tweenManager, arg1, arg2);
					}
					
					@Override
					public void onTransactionError(int arg0, String arg1) {
						// TODO Auto-generated method stub
						ctr.androidHelper.showToast(ctr.lang.payFailure);
					}
				});
			}		
		};
		ChangeListener noLis2 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();
				ctr.controller.callBankPurchase(new IAppotaPaymentProcessorListener() {
					
					@Override
					public void onTransactionSuccess(String arg0, String arg1, String arg2,
							int arg3) {
						// TODO Auto-generated method stub
						ctr.androidHelper.sendFinishTransaction(stage, tweenManager, arg1, arg2);
					}
					
					@Override
					public void onTransactionError(int arg0, String arg1) {
						// TODO Auto-generated method stub
						ctr.androidHelper.showToast(ctr.lang.payFailure);
					}
				});
			}		
		};
		ChangeListener noLis3 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();				
				ctr.controller.callPaypalPurchase(new IAppotaPaymentProcessorListener() {
					
					@Override
					public void onTransactionSuccess(String arg0, String arg1, String arg2,
							int arg3) {
						// TODO Auto-generated method stub
						ctr.androidHelper.sendFinishTransaction(stage, tweenManager, arg1, arg2);
					}
					
					@Override
					public void onTransactionError(int arg0, String arg1) {
						// TODO Auto-generated method stub
						ctr.androidHelper.showToast(ctr.lang.payFailure);
					}
				});
			}		
		};
		ok.addListener(okLis1);
		no.addListener(noLis1);
		no1.addListener(noLis2);		
		no2.addListener(noLis3);
		
		BackListener backLis = new BackListener(dialog, null, close, null, closeLis1,null);		
		ctr.d.backLis.add(backLis);
	}
	
	public void createDialogCoupon(final Stage stage,final TweenManager tweenManager, final String coupon){
		
		ctr.a.isHasDialog.add(0);				
		ctr.d.backLis.removeAllElements();
		Image dim = createImage(ctr.a.blackRegion, (-200), (-90),(800),(480));		
		dim.setColor(0f, 0f, 0f, 0.6f);
		
		final Table dialog = createTable(ctr.g.mSkin, (200), (90), (400), (300));		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (400), (300));	
		
		dialog.addActor(dim);
		Image bg = createImage(ctr.a.bgDialog_uof, 0, 0);
		bg.setSize(400, 300);
		bg.setOrigin(dialog.getWidth()/2, dialog.getHeight()/2);
		bg.setPosition((0), (0));
		dialog.addActor(bg);
		dialog.addActor(content);
		stage.addActor(dialog);
		bg.setScale(0.5f);
		content.setColor(1f, 1f, 1f, 0f);
		
		final ImageButton close = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 360, 260);	
		
		content.addActor(close);
		
		final ImageButton ok = createImageButton(ctr.g.mSkin, ctr.a.okNorRegion, ctr.a.okPressRegion, null, 0, 0,145,43);					

			ok.setPosition((120), (440-348-20));
			content.addActor(ok);				
			
			Label name;
			name = createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0);
			name.setText(ctr.lang.couponTitle);
			name.setPosition((100), (230));
		content.addActor(name);	
		
		final TextField input = new TextField("", ctr.g.mSkin);	
		input.setSize((250), (50));
		input.setPosition((60), (160));
		content.addActor(input);
		
		if(coupon!=null){
			input.setText(coupon);
		}
		ctr.inputTextAndroid.addTextField(input, true);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);	
		
		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				
				if(ctr.d.isNetworkAvaiable == false){
					ctr.androidHelper.showToast(ctr.lang.turnOnNetworkForTask);
				}
				
				if(input.getText().length()<=0){
					ctr.stageHelper.createDialog(stage, tweenManager, ctr.lang.youNotEnterCode, 1, null, null);
				}	
				else{
				if(input.getText().length()>13 || input.getText().length()<13){					
					ctr.stageHelper.createDialog(stage, tweenManager, ctr.lang.couponCode13Char, 1, null, null);					
				}				
				else{
					ctr.androidHelper.sendCoupon(stage, tweenManager, input.getText());
				}	
				}
			}
		};
			
		ChangeListener closeLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
			}
		};
		
		
		
		
		BackListener backLis = new BackListener(dialog, ok, close, okLis1, closeLis1,null);
		ctr.d.backLis.add(backLis);
	}
	
	public void createPopupAvatar(final BaseGameScreen screen, final Stage stage, final TweenManager tweenManager){
		
		ctr.a.isHasDialog.add(0);
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (400), (480));	
		//dialog.setScreen(screen);
		ImageButton but = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 0, 0, 800, 480);
		dialog.add(but);
		Image bg = createImage(ctr.a.bgDialogNoBoder, 0, 80,400,400);
		final Table content = createTable(ctr.g.mSkin, (0), (0), (400), (480));
			
		bg.setPosition((0), (80));
		dialog.addActor(bg);
		bg.setOrigin(0, 430);
		bg.setScale(0, 0);

		dialog.addActor(content);
		
		
		final IWMAction loginSuccess = new IWMAction() {					
			@Override
			public void action(String result) {						
				try{
				JSONObject jsObj = new JSONObject(result);
				// TODO Auto-generated method stub
				if (result == null) {
					ctr.d.isSendingLogin = false;
				} else {																				
					 if(jsObj.getString("code").equals("1")){
						 
						 ctr.d.name = ctr.d.namePre;
						 ctr.d.email = ctr.d.emailPre;
						 ctr.d.pass = ctr.d.passPre;	
						 
						 JSONObject content = jsObj.getJSONObject("content");
						 								 								 
						 JSONArray messages = content.getJSONArray("message");
						 
						 JSONArray gifts = content.getJSONArray("gift");

						 JSONArray advertise = content.getJSONArray("advertise");
						 
						 try{
						 JSONArray giftsDaily = content.getJSONArray("daily_gift");										
						 for(int i=0; i<giftsDaily.length(); i++){
								 JSONObject ele = giftsDaily.getJSONObject(i);
								 ctr.d.dailyGifts.add(new DailyGift(ele.getInt("zegome_gold"), ele.getString("message")));
							 }
						 }
						 catch(Exception ex){}
						 for(int i=0; i<messages.length(); i++){
							 JSONObject ele = messages.getJSONObject(i);
							 ctr.autoRunText.addNotify(0,ctr.d.isVietnamese?ele.getString("message_content"):ele.getString("message_eng"),null,null);
						 }

						 for(int i=0; i<advertise.length(); i++){
							 JSONObject ele = advertise.getJSONObject(i);
							 //ctr.a.notify.add(ele.getString("gift_id") +"-"+ele.getString("user_send")+"-"+ele.getString("zegome_gold")+"-"+ele.getString("coupon")+"-"+ele.getString("message"));
							 ctr.d.gameAdvertiseLoad.add(new GameAdvertise(i,ele.getString("icon"), ele.getString("link"), ctr.d.isVietnamese?ele.getString("message_vn"):ele.getString("message_eng")));
						 }
						 
						 for(int i=0; i<gifts.length(); i++){
							 JSONObject ele = gifts.getJSONObject(i);
							 //ctr.a.notify.add(ele.getString("gift_id") +"-"+ele.getString("user_send")+"-"+ele.getString("zegome_gold")+"-"+ele.getString("coupon")+"-"+ele.getString("message"));
							 ctr.d.gifts.add(new Gift(ele.getInt("gift_id"), ele.getString("user_send"), ele.getInt("zegome_gold"), ele.getString("coupon"), ele.getString("message")));
						 }
						 								
						 								 
						 ctr.d.moneyOnline = content.getInt("user_gome");
						 ctr.d.level = content.getInt("level");
						 ctr.d.total_win = content.getInt("total_win");
						 ctr.d.total_lose = content.getInt("total_lose");
						 ctr.d.achievement = content.getString("achievement");
						 ctr.d.exp = content.getInt("experiment");
						 ctr.d.star = content.getInt("star");
						 ctr.d.saveAccount();													 								 
						 ctr.stageHelper.dimissDialogLoading();
						 ctr.d.isLogined = true;
						 ctr.d.isHasAccount = true;
						 ctr.d.isSendingLogin = false;	
					 }
					 else {
						 screen.logout();
						 ctr.stageHelper.createDialogErrorLogin(stage, tweenManager, ctr.lang.error+": "+jsObj.getString("content"), 2, null);
						 ctr.d.isSendingLogin = false;
					 }
					 
				}
			}
				catch(Exception ex){
					ctr.androidHelper.log(ex.getMessage());
				}
			}
		};	
		
		
		final Image boderIcon = createImage(ctr.a.boderAvatar, 0, 480-128-10, 128+10, 128+10);
		
		final Image avatar = createImage(ctr.a.avatarMe, 5, 480-128-10+5, 128, 128);		
		
		//createButtonText("Đổi Avatar", 30, 170, 300, 55);
		final ImageButton ok = createImageButton(ctr.g.mSkin, ctr.a.changeAvatarNor, ctr.a.changeAvatarPress, null, 50, 110,300,55);
		
		//createButtonText("Nạp tiền", 30, 100, 300, 55);
		final ImageButton no = createImageButton(ctr.g.mSkin, ctr.a.shopButtonNor, ctr.a.shopButtonPress, null, 270, 355,120,72);
		
		final ImageButton no1 = createImageButton(ctr.g.mSkin, ctr.a.closeDialog, null, null, 370, 480-50);
		
		final ImageButton no2;
		
		if(ctr.d.isHasAccount){
		  no2 = createImageButton(ctr.g.mSkin, ctr.a.logoutPopUpNor, ctr.a.logoutPopUpPress, null, 50, 190, 300, 55);
		}
		else{
			no2 = createImageButton(ctr.g.mSkin, ctr.a.loginPopUpNor, ctr.a.loginPopUpPress, null, 50, 190, 300, 55);
		}
		
		Label name, money, moneyOnline;
		
		name = createLabel(ctr.g.mFont, (ctr.d.name.equals("")?"Noname":ctr.d.name), Color.WHITE, 143, 420);
		
		moneyOnline = createLabel(ctr.g.mFont, ctr.d.moneyOnline+"" , Color.WHITE, 175, 385);
		
		money = createLabel(ctr.g.mFont, ctr.d.money+"", Color.WHITE, 175, 350);
						
		final Image gomeIcon = createImage(ctr.a.iconGomeMoney, 140, 378);
		
		final Image onlineIcon = createImage(ctr.a.onlineGomeMoney, 140, 355, 30, 30);
		
		
		content.addActor(avatar);		
		content.addActor(boderIcon);;

		content.addActor(ok);
		content.addActor(no);
		content.addActor(no1);		
		content.addActor(gomeIcon);
		content.addActor(money);		
		content.addActor(name);
		
		if(ctr.d.isHasAccount && ctr.d.isLogined)
			starGen(content, 0, 480-225, ctr.d.star, ctr.d.getTypeAchievement(), 2,true,ctr.d.achievement,ctr.d.exp);
		
		//if(ctr.d.isLogined){
			content.addActor(moneyOnline);
			content.addActor(onlineIcon);
		//}
			if(ctr.d.isLogined == false)
				moneyOnline.setText("");
//		if(ctr.d.isLogined == false){
//			onlineIcon.setVisible(false);
//		}

		content.setColor(1f, 1f, 1f, 0f);
						
		ChangeListener noLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();
				if(ctr.d.isHasAccount)
				{
					if(ctr.d.isNetworkAvaiable){						
						createDialogMoney(screen, stage, tweenManager);												
					}
					else{
						createDialog(stage, tweenManager, ctr.lang.turnOnNetworkForTask, 1, null, null);
					}
				}
				else{
					createDialogLogin(stage, tweenManager, "", "", loginSuccess,
							null,null,null);
				}
			}		
		};
		ChangeListener noLis2 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();				
			}		
		};

		
		ChangeListener noLis3 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();								
				if(ctr.d.isHasAccount == false)
					createDialogLogin(stage, tweenManager, "", "", loginSuccess,
						null,null,null);
				else{
					createDialog(stage, tweenManager, ctr.lang.getExitAccout(), 2,
							new ChangeListener() {
						@Override
						public void changed(ChangeEvent event, Actor actor) {							
							
							ctr.a.yesSound.play(ctr.a.vls);
							dialog.remove();				
							
							createDialogLoading(stage, tweenManager);
							
							new Thread(new Runnable() {
								
								@Override
								public void run() {
									// TODO Auto-generated method stub
									while (ctr.d.isSendingAvatar||ctr.d.isSendingGetSessionId||ctr.d.isSendingLogin||ctr.d.isSyncingNewAvatar) {																		
									}
									
									ctr.d.isHasAccount=false;

									
									ctr.d.isLogined = false;	

																	
									ctr.d.isSendingGetSessionId = false;
									ctr.d.isHasSessionId = false;
																		
									ctr.d.isSendingAvatar = false;
									ctr.d.isCheckAvatar = false;
									
									ctr.d.timeAvatar = "2012-09-24 00:00:01";
								    ctr.d.isNewAvatarNotSync = false;
									ctr.d.isSyncingNewAvatar = false;
									ctr.d.isSyncedNewAvatar = false;
									ctr.d.saveAvatarInfo();
									
									ctr.d.moneyOnline = 0;
									ctr.d.name = "";	
									ctr.d.email = "";
									ctr.d.pass = "";										
									
									ctr.d.namePre = "";	
									ctr.d.passPre = "";		
																											
									ctr.d.saveAccount();
									
									 screen.postRunnable(new Runnable() {
											
											@Override
											public void run() {
												// TODO Auto-generated method stub
												TextureAtlas cm2Atlas = ctr.controller.get(ctr.g.ASSET_FOLDER_DATA+"commond/commond2.atlas", TextureAtlas.class);
												ctr.a.avatarMe = cm2Atlas.findRegion("avatar");	
												ctr.a.avatarMe.setRegionWidth(64);
												ctr.a.avatarMe.setRegionHeight(64);
												ctr.stageHelper.avatar.setDrawable(new TextureRegionDrawable(ctr.a.avatarMe));
											}
										});
									
									dimissDialogLoading();
								}
							}).start();
						}
					}
							, null);
				}
			}		
		};
		
		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();				
				if(ctr.d.isHasAccount){					
					if(ctr.d.isNetworkAvaiable){
						if(ctr.d.isLogined()){
							screen.setWaitAction(new IMActionBoolean() {
								
								@Override
								public boolean isFinish() {
									// TODO Auto-generated method stub
									return ctr.d.isLogined();
								}
								
								@Override
								public void end() {
									// TODO Auto-generated method stub
									ctr.stageHelper.dimissDialogLoading();
									D.nameClone = ctr.d.name;
									ctr.androidHelper.showDialogPickPhoto();
								}
								
								@Override
								public void begin() {
									// TODO Auto-generated method stub
									ctr.stageHelper.createDialogLoading(stage, tweenManager);
								}
							});
						}
						else
							ctr.androidHelper.showDialogPickPhoto();
					}
					else{
						createDialog(stage, tweenManager, ctr.lang.turnOnNetworkForTask, 1, null, null);
					}
				}
				else{
					createDialogLogin(stage, tweenManager, "", "", loginSuccess,
							null,null,null);
				}
			}
		};
		
		ok.addListener(okLis1);
		no.addListener(noLis1);
		//no1.addListener(noLis2);
		no2.addListener(noLis3);
		
		bg.setScale(0);
		
		but.addListener(new ChangeListener() {			
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub				
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.yesSound.play(ctr.a.vls);
				dialog.remove();
			}
		});
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quart.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1f).ease(Quad.OUT)
				.start(tweenManager);
			}
		})
		.start(tweenManager);
		
		//if(ctr.d.isHasAccount==false){
			content.addActor(no2);
		//}
		
			
		stage.addActor(dialog);
		
		final BackListener back = new BackListener(dialog, null, no1, null, noLis2, null);
		ctr.d.backLis.add(back);
		
	}
	
	public ImageButton createButtonText(String text,int x, int y, int wi, int hi){
		ImageButton temp = null;
		temp = createImageButton(ctr.g.mSkin, ctr.a.buttonBlank, ctr.a.buttonBlank, null, x, y, wi, hi);
		Label label = createLabel(ctr.g.mFont, text, Color.WHITE, 0, 0); 		
		temp.addActor(label);
		float xL = (wi-label.getTextBounds().width)/2;
		float yL = (hi-label.getTextBounds().height)/2-5;
		label.setPosition(xL, yL);
		return temp;
	}
	
	public void createDialogWin(final Stage stage,final TweenManager tweenManager,int starNumber, int pikaNumber, int comboNumber,float timeLeft,int chapter, int level, final ChangeListener menuLis, final ChangeListener replayLis, final ChangeListener nextLis){		

		ctr.a.win.play(ctr.a.vls);
		
		ctr.a.isHasDialog.add(1);		
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (151), (30), (498), (295));
		final Table content = createTable(ctr.g.mSkin, (0), (0), (498), (295));
		
		Image bg = createImage(ctr.a.bgDialog_uof, 0, 0);
		Image dim = createImage(ctr.a.blackRegion, (-151), (-30),(800),(480));
		
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);
		bg.setSize((498), (295));
		bg.setOrigin(dialog.getWidth()/2, dialog.getHeight()/2);
		bg.setPosition((0), (0));
		bg.setScale(0.5f);
		dialog.addActor(bg);
		stage.addActor(dialog);
		dialog.addActor(content);
		
		Image pikaWin = createImage(ctr.a.gomeWinDialog_uof, 100, 200);
		content.addActor(pikaWin);
		
		Image[] star = new Image[3] ;
		
		if(starNumber >= 0){
			for(int i=0;i<3;i++){
				star[i] = createImage(ctr.a.starRegion, (150)+i*50, (210));				
				if(starNumber>=(i+1)){
					content.addActor(new ParticleActor(new ParticalDrawable(150+150+i*50+30, 30+210+30)));
					star[i].setColor(1f, 1f, 1f, 1f);
				}
				else{
					star[i].setColor(0.5f, 0.5f, 0.5f, 1f);
				}
				content.addActor(star[i]);
			}
		}				
		
		Label total;
		total = createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0);
		total.setText(ctr.lang.youWin);
		total.setPosition((150), (295-106));
		content.addActor(total);	
		
		
		int moneyPlus = 0;
		if(chapter == 7){
			moneyPlus = (int)(100 + (0 * 50)  + ((level-140) * 2) + timeLeft/10 + 1);
		}
		else{
			moneyPlus  = (int)(100 + (chapter * 50)  + (level * 2) + timeLeft/10 + 1);
		}
		Label money;
		money = createLabel(ctr.g.mFontCombo, "", Color.WHITE, 0, 0);
		money.setText("+"+moneyPlus);
		money.setPosition((170+45*1.5f), (295-155));
		content.addActor(money);	
		Image diamond = createImage(ctr.a.onlineGomeMoney, 170, 299-155-20);
		diamond.setScale(1.5f);
		content.addActor(diamond);
		
		ctr.d.money += moneyPlus;
		
		ctr.d.saveAccount();
		
		ImageButton menu = createImageButton(ctr.g.mSkin, ctr.a.menuDialog_uof, ctr.a.menuDialog_uof, null, (44), (40));
		
		menu.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				menuLis.changed(arg0, arg1);
			}
		});
		
		content.addActor(menu);
		
		
		ImageButton replay = createImageButton(ctr.g.mSkin, ctr.a.replayDialog_uof, ctr.a.replayDialog_uof, null, (179), (40));
		replay.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				replayLis.changed(arg0, arg1);
			}
		});
		content.addActor(replay);
		
		ImageButton next = createImageButton(ctr.g.mSkin, ctr.a.nextDialog_uof, ctr.a.nextDialog_uof, null, (334), (40));
		next.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				nextLis.changed(arg0, arg1);
			}
		});
		content.addActor(next);
				
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);
	}
	
	public void createDialogWinVS(final Stage stage, final TweenManager tweenManager,String name1s, String name2s, int pika1s, int combo1s, int pika2s, int combo2s , final ChangeListener menuLis, final ChangeListener replayLis, final ChangeListener nextLis){
		
		//Log.e("ABCABC", "AAAAAAAAAAAAAAAAAAA");
		
		ctr.a.win.play(ctr.a.vls);
		
		ctr.a.isHasDialog.add(1);		
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (151), (93), (498), (295));
		final Table content = createTable(ctr.g.mSkin, (0), (0), (498), (295));
		
		final Table info  = createTable(ctr.g.mSkin, 140, 0-22, 300, 295);
		final Table info2 = createTable(ctr.g.mSkin, 10, 0-22, 100, 295);
		//info.defaults().row().height(30).width(100);
		
		Image pikaWin = createImage(ctr.a.gomeWinDialog_uof, 100, 150);
		content.addActor(pikaWin);
		
		content.addActor(info);
		content.addActor(info2);
		
		Image dim = createImage(ctr.a.blackRegion, (-151), (-93),(800),(480));
		
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);
		Image bg = createImage(ctr.a.bgDialog_uof, 0, 0);
		bg.setSize((498), (295+100));
		bg.setOrigin(dialog.getWidth()/2, dialog.getHeight()/2);
		bg.setPosition((0), (-90));
		bg.setScale(0.5f);
		dialog.addActor(bg);
		stage.addActor(dialog);
		dialog.addActor(content);
		
		int width = 150;
		int height = 50;
		
		Label combo0 = createLabel(ctr.g.mFont, "EXP", Color.WHITE, 0, 0);
		//combo0.setBounds(0, 0, width, height);
		//combo0.setAlignment(Align.left|Align.bottom);
		combo0.setWrap(true);
		//combo0.setPosition((20), (150));		
		
		Label pika0 = createLabel(ctr.g.mFont,  ctr.lang.score, Color.WHITE, 0, 0);		
		//pika0.setBounds(0, 0, width, height);
		//pika0.setAlignment(Align.left|Align.bottom);
		pika0.setWrap(true);
		//pika0.setPosition((20), (200));
		//content.addActor(pika0);		
		
		Image total0 = createImage(ctr.a.iconGomeMoney, 0, 0);		
		total0.setAlign(Align.left|Align.bottom);
		total0.setPosition(50, 0-22+40+55);
		
		//total0.setPosition((20), (100));
		//content.addActor(total0);	
		
		Image money0 = createImage(ctr.a.onlineGomeMoney, 0, 0);		
		money0.setAlign(Align.left|Align.bottom);
		money0.setPosition(50, 0-2+40);
		//money0.setPosition((20), (50));
		//content.addActor(money0);
		
		Label user1 = createLabel(ctr.g.mFont, ""+name1s, Color.WHITE, 0, 0);
		if(name1s.length()>10){
			user1.setText(name1s.substring(0, 5)+"..."+name1s.substring(name1s.length()-2, name1s.length()));
		}
		user1.setBounds(0, 0, width, height);
		user1.setAlignment(Align.center|Align.bottom);
		user1.setWrap(true);
		//user1.setPosition((140), (250));
		//content.addActor(user1);
		
		Label combo1 = createLabel(ctr.g.mFont, "+"+combo1s, Color.WHITE, 0, 0);
		combo1.setBounds(0, 0, width, height);
		combo1.setAlignment(Align.center|Align.bottom);
		combo1.setWrap(true);
		//combo1.setPosition((140), (150));
		//content.addActor(combo1);		
		
		Label pika1 = createLabel(ctr.g.mFont,  ""+pika1s, Color.WHITE, 0, 0);
		pika1.setBounds(0, 0, width, height);
		pika1.setAlignment(Align.center|Align.bottom);
		pika1.setWrap(true);
		//pika1.setPosition((140), (200));
		//content.addActor(pika1);		
		
		Label total1 = createLabel(ctr.g.mFont, ""+(ctr.d.typeBet==1?("+"+ctr.d.receive):"+0"), Color.WHITE, 0, 0);	
		total1.setBounds(0, 0, width, height);
		total1.setAlignment(Align.center|Align.bottom);
		total1.setWrap(true);
		//total1.setPosition((140), (100));
		//content.addActor(total1);	
		
		Label money1 = createLabel(ctr.g.mFont, ""+(ctr.d.typeBet==2?("+"+ctr.d.betNum*2*0.7f):"+0"), Color.WHITE, 0, 0);	
		money1.setBounds(0, 0, width, height);
		money1.setAlignment(Align.center|Align.bottom);
		money1.setWrap(true);
		//money1.setPosition((140), (50));
		//content.addActor(money1);	
		
		
		Label user2 = createLabel(ctr.g.mFont, ""+name2s, Color.WHITE, 0, 0);
		//user2.setPosition((310), (250));
		//content.addActor(user2);
		if(name2s.length()>10){
			user2.setText(name2s.substring(0, 5)+"..."+name2s.substring(name2s.length()-2, name2s.length()));
		}
		user2.setBounds(0, 0, width, height);
		user2.setAlignment(Align.center|Align.bottom);
		user2.setWrap(true);
		
		Label combo2 = createLabel(ctr.g.mFont, ""+combo2s, Color.WHITE, 0, 0);
		combo2.setBounds(0, 0, width, height);
		combo2.setAlignment(Align.center|Align.bottom);
		combo2.setWrap(true);
		//combo2.setPosition((310), (150));
		//content.addActor(combo2);		
		
		Label pika2 = createLabel(ctr.g.mFont,  ""+pika2s, Color.WHITE, 0, 0);		
		pika2.setBounds(0, 0, width, height);
		pika2.setAlignment(Align.center|Align.bottom);
		pika2.setWrap(true);
		//pika2.setPosition((310), (200));
		//content.addActor(pika2);		
		
		Label total2 = createLabel(ctr.g.mFont, ""+(ctr.d.typeBet==1?("+"+ctr.d.receiveB):"+0"), Color.WHITE, 0, 0);	
		total2.setBounds(0, 0, width, height);
		total2.setAlignment(Align.center|Align.bottom);
		total2.setWrap(true);
		//total2.setPosition((310), (100));
		//content.addActor(total2);	
		
		Label money2 = createLabel(ctr.g.mFont, ""+(ctr.d.typeBet==2?("+0"):"+0"), Color.WHITE, 0, 0);	
		money2.setBounds(0, 0, width, height);
		money2.setAlignment(Align.center|Align.bottom);
		money2.setWrap(true);
		//money2.setPosition((310), (50));
		//content.addActor(money2);
		
		//info.row();
		
		info2.add(createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0)).height(height);
		info2.row();
		info2.add(pika0).align(Align.left|Align.bottom).height(height);
		info2.row();
		info2.add(combo0).align(Align.left|Align.bottom).height(height);
		info2.row();
		info2.add(createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0)).align(Align.left|Align.bottom).height(height);
		info2.row();
		info2.add(createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0)).align(Align.left|Align.bottom).height(height);
		info2.addActor(total0);
		info2.addActor(money0);
		
		info.add(user1).width(width);
		info.add(user2).width(width);
		info.row();
		info.add(pika1).width(width);
		info.add(pika2).width(width);
		info.row();
		info.add(combo1).width(width);
		info.add(combo2).width(width);
		info.row();
		info.add(total1).width(width);
		info.add(total2).width(width);
		info.row();
		info.add(money1).width(width);
		info.add(money2).width(width);
		
		ImageButton menu = createImageButton(ctr.g.mSkin, ctr.a.okNorRegion, ctr.a.okPressRegion, null, (44+130), (-37-16));
		menu.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				if(menuLis!=null)
				menuLis.changed(arg0, arg1);
			}
		});
		content.addActor(menu);
		
		ImageButton replay = createImageButton(ctr.g.mSkin, ctr.a.replayDialog_uof, ctr.a.replayDialog_uof, null, (179), (-37-22));
		replay.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				replayLis.changed(arg0, arg1);
			}
		});
		//content.addActor(replay);
		
		ImageButton next = createImageButton(ctr.g.mSkin, ctr.a.nextDialog_uof, ctr.a.nextDialog_uof, null, (334), (-37-22));
		next.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				nextLis.changed(arg0, arg1);
			}
		});
		//content.addActor(next);
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);
	}
	
	
public void createDialogLoseVS2(final Stage stage, final TweenManager tweenManager,String name1s, String name2s, int pika1s, int combo1s, int pika2s, int combo2s , final ChangeListener menuLis, final ChangeListener replayLis){
		
		ctr.a.lose.play(ctr.a.vls);
		ctr.a.isHasDialog.add(1);		
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (151), (93), (498), (295));
		final Table content = createTable(ctr.g.mSkin, (0), (0), (498), (295));
		
		final Table info  = createTable(ctr.g.mSkin, 140, 0-22, 300, 295);
		final Table info2 = createTable(ctr.g.mSkin, 10, 0-22, 100, 295);
		//info.defaults().row().height(30).width(100);
		
		Image pikaWin = createImage(ctr.a.gomeLoseDialog_uof, 150, 220);
		content.addActor(pikaWin);
		
		content.addActor(info);
		content.addActor(info2);
		Image dim = createImage(ctr.a.blackRegion, (-151), (-93),(800),(480));
		
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);
		Image bg = createImage(ctr.a.bgDialog_uof, 0, 0);
		bg.setSize((498), (295+100));
		bg.setOrigin(dialog.getWidth()/2, dialog.getHeight()/2);
		bg.setPosition((0), (-90));
		bg.setScale(0.5f);
		dialog.addActor(bg);
		stage.addActor(dialog);
		dialog.addActor(content);
		
		int width = 150;
		int height = 50;
		
		Label combo0 = createLabel(ctr.g.mFont, "EXP", Color.WHITE, 0, 0);
		//combo0.setBounds(0, 0, width, height);
		//combo0.setAlignment(Align.left|Align.bottom);
		combo0.setWrap(true);
		//combo0.setPosition((20), (150));		
		
		Label pika0 = createLabel(ctr.g.mFont,  ctr.lang.score, Color.WHITE, 0, 0);		
		//pika0.setBounds(0, 0, width, height);
		//pika0.setAlignment(Align.left|Align.bottom);
		pika0.setWrap(true);
		//pika0.setPosition((20), (200));
		//content.addActor(pika0);		
		
		Image total0 = createImage(ctr.a.iconGomeMoney, 0, 0);		
		total0.setAlign(Align.left|Align.bottom);
		total0.setPosition(50, 0-22+40+55);
		
		//total0.setPosition((20), (100));
		//content.addActor(total0);	
		
		Image money0 = createImage(ctr.a.onlineGomeMoney, 0, 0);		
		money0.setAlign(Align.left|Align.bottom);
		money0.setPosition(50, 0-2+40);
		//money0.setPosition((20), (50));
		//content.addActor(money0);
		
		Label user1 = createLabel(ctr.g.mFont, ""+name1s, Color.WHITE, 0, 0);
		if(name1s.length()>10){
			user1.setText(name1s.substring(0, 5)+"..."+name1s.substring(name1s.length()-2, name1s.length()));
		}
		user1.setBounds(0, 0, width, height);
		user1.setAlignment(Align.center|Align.bottom);
		user1.setWrap(true);
		//user1.setPosition((140), (250));
		//content.addActor(user1);
		
		Label combo1 = createLabel(ctr.g.mFont, ""+combo1s, Color.WHITE, 0, 0);
		combo1.setBounds(0, 0, width, height);
		combo1.setAlignment(Align.center|Align.bottom);
		combo1.setWrap(true);
		//combo1.setPosition((140), (150));
		//content.addActor(combo1);		
		
		Label pika1 = createLabel(ctr.g.mFont,  ""+pika1s, Color.WHITE, 0, 0);
		pika1.setBounds(0, 0, width, height);
		pika1.setAlignment(Align.center|Align.bottom);
		pika1.setWrap(true);
		//pika1.setPosition((140), (200));
		//content.addActor(pika1);		
		
		Label total1 = createLabel(ctr.g.mFont, ""+(ctr.d.typeBet==1?("+0"):"+0"), Color.WHITE, 0, 0);	
		total1.setBounds(0, 0, width, height);
		total1.setAlignment(Align.center|Align.bottom);
		total1.setWrap(true);
		//total1.setPosition((140), (100));
		//content.addActor(total1);	
		
		Label money1 = createLabel(ctr.g.mFont, "+0", Color.WHITE, 0, 0);	
		money1.setBounds(0, 0, width, height);
		money1.setAlignment(Align.center|Align.bottom);
		money1.setWrap(true);
		//money1.setPosition((140), (50));
		//content.addActor(money1);	
		
		
		Label user2 = createLabel(ctr.g.mFont, ""+name2s, Color.WHITE, 0, 0);
		if(name2s.length()>10){
			user2.setText(name2s.substring(0, 5)+"..."+name2s.substring(name2s.length()-2, name2s.length()));
		}
		//user2.setPosition((310), (250));
		//content.addActor(user2);
		user2.setBounds(0, 0, width, height);
		user2.setAlignment(Align.center|Align.bottom);
		user2.setWrap(true);
		
		Label combo2 = createLabel(ctr.g.mFont, ""+combo2s, Color.WHITE, 0, 0);
		combo2.setBounds(0, 0, width, height);
		combo2.setAlignment(Align.center|Align.bottom);
		combo2.setWrap(true);
		//combo2.setPosition((310), (150));
		//content.addActor(combo2);		
		
		Label pika2 = createLabel(ctr.g.mFont,  ""+pika2s, Color.WHITE, 0, 0);		
		pika2.setBounds(0, 0, width, height);
		pika2.setAlignment(Align.center|Align.bottom);
		pika2.setWrap(true);
		//pika2.setPosition((310), (200));
		//content.addActor(pika2);		
		
		Label total2 = createLabel(ctr.g.mFont, ""+(ctr.d.typeBet==1?("+"+ctr.d.receiveB):"+0"), Color.WHITE, 0, 0);	
		total2.setBounds(0, 0, width, height);
		total2.setAlignment(Align.center|Align.bottom);
		total2.setWrap(true);
		//total2.setPosition((310), (100));
		//content.addActor(total2);	
		
		Label money2 = createLabel(ctr.g.mFont, ""+(ctr.d.typeBet==2?("+"+ctr.d.betNum*2*0.7f):"+0"), Color.WHITE, 0, 0);	
		money2.setBounds(0, 0, width, height);
		money2.setAlignment(Align.center|Align.bottom);
		money2.setWrap(true);
		//money2.setPosition((310), (50));
		//content.addActor(money2);
		
		//info.row();
		
		info2.add(createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0)).height(height);
		info2.row();
		info2.add(pika0).align(Align.left|Align.bottom).height(height);
		info2.row();
		info2.add(combo0).align(Align.left|Align.bottom).height(height);
		info2.row();
		info2.add(createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0)).align(Align.left|Align.bottom).height(height);
		info2.row();
		info2.add(createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0)).align(Align.left|Align.bottom).height(height);
		info2.addActor(total0);
		info2.addActor(money0);
		
		info.add(user1).width(width);
		info.add(user2).width(width);
		info.row();
		info.add(pika1).width(width);
		info.add(pika2).width(width);
		info.row();
		info.add(combo1).width(width);
		info.add(combo2).width(width);
		info.row();
		info.add(total1).width(width);
		info.add(total2).width(width);
		info.row();
		info.add(money1).width(width);
		info.add(money2).width(width);
		
		ImageButton menu = createImageButton(ctr.g.mSkin, ctr.a.okNorRegion, ctr.a.okPressRegion, null, (44+130), (-37-16));
		menu.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				menuLis.changed(arg0, arg1);
			}
		});
		content.addActor(menu);
		
		ImageButton replay = createImageButton(ctr.g.mSkin, ctr.a.replayDialog_uof, ctr.a.replayDialog_uof, null, (179+30+40+20), (-37-22));
		replay.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				replayLis.changed(arg0, arg1);
			}
		});
		//content.addActor(replay);
		
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);
	}
	
	public void createDialogLose(Stage stage, final TweenManager tweenManager,int pikaNumber, int comboNumber,final ChangeListener menuLis, final ChangeListener replayLis){		
		ctr.a.lose.play(ctr.a.vls);
		ctr.a.isHasDialog.add(1);		
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (151), (80), (498), (295));
		final Table content = createTable(ctr.g.mSkin, (0), (0), (498), (295));
		Image bg = createImage(ctr.a.bgDialog_uof, 0, 0);
		Image dim = createImage(ctr.a.blackRegion, (-151), (-80),(800),(480));
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);
		bg.setSize((498), (295));
		bg.setOrigin(dialog.getWidth()/2, dialog.getHeight()/2);
		bg.setPosition((0), (0));
		bg.setScale(0.5f);
		dialog.addActor(bg);
		stage.addActor(dialog);
		dialog.addActor(content);
				
		Label total;
		total = createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0);
		total.setText(ctr.lang.score+": "+(int)((pikaNumber+comboNumber)*50));
		total.setPosition((190), (295-170));
		content.addActor(total);	
		
		Label money;
		money = createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0);
		money.setText(ctr.lang.youLose);
		money.setPosition((150), (295-106));
		content.addActor(money);	
		
		Image pikaWin = createImage(ctr.a.gomeLoseDialog_uof, 163, 295-79);
		
		content.addActor(pikaWin);
				
		ImageButton menu = createImageButton(ctr.g.mSkin, ctr.a.menuDialog_uof, ctr.a.menuDialog_uof, null, (150), (40));
		menu.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				menuLis.changed(arg0, arg1);
			}
		});
		
		content.addActor(menu);
		
		
		ImageButton replay = createImageButton(ctr.g.mSkin, ctr.a.replayDialog_uof, ctr.a.replayDialog_uof, null, (280), (40));
		replay.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				replayLis.changed(arg0, arg1);
			}
		});
		content.addActor(replay);
		
		ImageButton next = createImageButton(ctr.g.mSkin, ctr.a.nextDialog_uof, ctr.a.nextDialog_uof, null, (334), (40));
		next.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				//nextLis.changed(arg0, arg1);
			}
		});
				
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);
	}
		
	public void dimissDialogLoading(){
		if(dialogLoading!=null){
			ctr.a.isHasDialog.removeElementAt(0);
			dialogLoading.remove();
			dialogLoading.clear();
			dialogLoading = null;
		}
	}
	
	public void createDialogLoading(Stage stage,final TweenManager tweenManager){
		if(dialogLoading!=null && dialogLoading.isVisible() == true)
			return;
		ctr.a.isHasDialog.add(1);	
		ctr.d.backLis.removeAllElements();
		dialogLoading = createTable(ctr.g.mSkin, (300), (190), (200), (100));
		final Table content = createTable(ctr.g.mSkin, (0), (0), (200), (100));
		Image dim = createImage(ctr.a.blackRegion, (-300), (-190),(800),(480));
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialogLoading.addActor(dim);
		Image bg = createImage(ctr.a.bgDialog_uof, 0, 0);
		bg.setSize((200), (100));
		bg.setOrigin(dialogLoading.getWidth()/2, dialogLoading.getHeight()/2);
		bg.setPosition((0), (0));
		bg.setScale(0.5f);
		dialogLoading.addActor(bg);
		stage.addActor(dialogLoading);
		dialogLoading.addActor(content);
	
		LoadingActor loading = new LoadingActor(new TextDrawable(ctr.g.mFont));
		loading.setPosition(40, 10);
		content.addActor(loading);
		loading.setPosition(40, 70);
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);
		
		//ctr.androidHelper.log(dialogLoading.isVisible() +""+ (dialogLoading.getStage() == stage)+""+dialogLoading.getWidth()+"-"+dialogLoading.getHeight());
	}
	
public void createDialogPause(Stage stage,final TweenManager tweenManager, final ChangeListener menuLis, final ChangeListener replayLis){
		
		ctr.a.isHasDialog.add(1);		
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (151), (166), (498), (148));
		final Table content = createTable(ctr.g.mSkin, (0), (0), (498), (148));
		Image dim = createImage(ctr.a.blackRegion, (-151), (-166),(800),(480));
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);
		Image bg = createImage(ctr.a.bgDialog_uof, 0, 0);
		bg.setSize((496), (148));
		bg.setOrigin(dialog.getWidth()/2, dialog.getHeight()/2);
		bg.setPosition((0), (0));
		bg.setScale(0.5f);
		dialog.addActor(bg);
		stage.addActor(dialog);
		dialog.addActor(content);
		
		ImageButton menu = createImageButton(ctr.g.mSkin, ctr.a.menuDialog_uof, ctr.a.menuDialog_uof, null, (44), (45));
		menu.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				menuLis.changed(arg0, arg1);
			}
		});
		content.addActor(menu);
		
		ImageButton replay = createImageButton(ctr.g.mSkin, ctr.a.replayDialog_uof, ctr.a.replayDialog_uof, null, (179), (45));
		replay.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				replayLis.changed(arg0, arg1);
			}
		});
		content.addActor(replay);
		
		ImageButton next = createImageButton(ctr.g.mSkin, ctr.a.nextDialog_uof, ctr.a.nextDialog_uof, null, (334), (45));
		next.addListener(new ChangeListener() {						
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();				
			}
		});
		content.addActor(next);
				
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);
	}
	
	
	public void createDialogSaveMap(final Stage stage, final TweenManager tweenManager,final String map, final int chapter, final ChangeListener okLis){
		ctr.a.isHasDialog.add(1);		
		ctr.d.backLis.removeAllElements();
		final Table dialog = createTable(ctr.g.mSkin, (67), (20), (667), (440));		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (667), (440));	
		Image bg = createImage(ctr.a.loginBgDialog_uof, 0, 0);
		Image dim = createImage(ctr.a.blackRegion, (-67), (-20),(800),(480));
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);
		bg.setOrigin(dialog.getWidth()/2, dialog.getHeight()/2);
		bg.setPosition((0), (0));
		dialog.addActor(bg);
		dialog.addActor(content);
		stage.addActor(dialog);
		bg.setScale(0.5f);
		final ImageButton ok = createImageButton(ctr.g.mSkin, ctr.a.okNorRegion, ctr.a.okPressRegion, null, 0, 0,145,43);					

			ok.setPosition((260), (440-348));
			content.addActor(ok);			
	
			
			Label name;
			name = createLabel(ctr.g.mFont, "", Color.WHITE, 0, 0);
			name.setText(ctr.lang.titleSavemap);
			name.setPosition((260), (250));
		content.addActor(name);		
		
		final TextField input = new TextField("", ctr.g.mSkin);	
		input.setMaxLength(10);
		input.setSize((250), (50));
		input.setPosition((200), (180));
		content.addActor(input);
		ctr.inputTextAndroid.addTextField(input, false);

		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);
		
		
		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {	
				if(ctr.d.passTask[D.TASK_DRAW] == false){
					ctr.a.isHasDialog.removeElementAt(0);
					dialog.remove();
					ctr.d.passTask[D.TASK_DRAW] = true;
					ctr.d.money += 500;
					ctr.d.saveAccount();
					createDialog(stage, tweenManager, ctr.lang.bonusDiamond,1,
							new ChangeListener() {								
								@Override
								public void changed(ChangeEvent arg0, Actor arg1) {
									// TODO Auto-generated method stub
									ctr.d.addMap(input.getText(), chapter, map);
									ctr.d.saveAllMap();
									okLis.changed(arg0, arg1);
								}
							}, null);
				}
				else{
				ctr.a.isHasDialog.removeElementAt(0);
				dialog.remove();
				ctr.d.addMap(input.getText(), chapter, map);
				ctr.d.saveAllMap();
				okLis.changed(event, actor);
				}
			}
		};		
		if(okLis1!=null){
			ok.addListener(okLis1);
		}
	}
	
	public void createDialogLogin(final Stage stage, final TweenManager tweenManager,String userStr, String passStr,final IWMAction process, final ChangeListener backLoginLis, final ChangeListener backRegLis, final ChangeListener noRegLis){

		ctr.a.isHasDialog.add(1);	
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (66), (20), (667), (440));
		final Table content = createTable(ctr.g.mSkin, (0), (0), (667), (440));
		Image dim = createImage(ctr.a.blackRegion, (-67), (-20),(800),(480));		
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);
		
		Image bg = createImage(ctr.a.loginBgDialog_uof, 0, 0);
		bg.setSize((667*1.2f), (440*1.2f));
		bg.setOrigin(dialog.getWidth()/2, dialog.getHeight()/2);
		bg.setPosition((-67), (-44));
		dialog.addActor(bg);
		dialog.addActor(content);
		stage.addActor(dialog);
		bg.setScale(0.5f);		
		
		final ImageButton ok = createImageButton(ctr.g.mSkin, ctr.a.loginNorDialog_uof, ctr.a.loginPressDialog_uof, null, 0, 0,143,43);
		ImageButton no = createImageButton(ctr.g.mSkin, ctr.a.regNorDialog_uof, ctr.a.regPressDialog_uof, null, 0, 0,143,43);
		ImageButton reset = createImageButton(ctr.g.mSkin, ctr.a.resetPass, ctr.a.resetPass2, null, 0, 0,143,43);			
			no.setPosition(85, 50);
			content.addActor(no);
			ok.setPosition((255), (50));
			content.addActor(ok);
			reset.setPosition((435), (50));
			content.addActor(reset);
		
					
		final TextField input = new TextField("", ctr.g.mSkin);		
		input.getStyle().font = ctr.g.mFont;
		input.setSize((250), (50));
		input.setMessageText(ctr.lang.user);
		input.setMaxLength(20);
		input.setPosition((200), (240));
		input.setText(userStr);
		content.addActor(input);
		
		final TextField pass = new TextField("", ctr.g.mSkin);
		
		pass.getStyle().font = ctr.g.mFont;
		pass.setSize((250), (50));
		pass.setPasswordCharacter('*');
		pass.setPasswordMode(true);
		pass.setMessageText(ctr.lang.pass);
		pass.setText(passStr);
		pass.setPosition((200), (160));
		content.addActor(pass);
		content.addActor(createLabel(ctr.g.mFont, ctr.lang.saveAccount, Color.WHITE, (240), (110)));
		content.addActor(createCheckBox((200), (110), 0, 0));
		
		ctr.inputTextAndroid.addTextField(input, true);
		ctr.inputTextAndroid.addTextField(pass, true);
		
		content.setColor(1f,1f,1f,0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				//content.setColor(1f, 1f, 1f, 0.2f);
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);	
		
		ChangeListener resetLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {	
				
				if(ctr.androidHelper.isNetworkAvailable() == false){
					createDialog(stage, tweenManager, ctr.lang.turnOnNetworkForTask, 1, null, null);
					return;
				}		
				dialog.remove();
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.androidHelper.openlink(LINK_RESET);
			}
		};	
		
		reset.addListener(resetLis1);
		
		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {	
				
				if(ctr.androidHelper.isNetworkAvailable() == false){
					createDialog(stage, tweenManager, ctr.lang.turnOnNetworkForTask, 1, null, null);
					return;
				}		
				
				if(input.getText().length()==0 || pass.getText().length()==0){
					ctr.androidHelper.showToast(ctr.lang.inputNotEnough);
					return;
				}
				
				
				ctr.d.namePre = input.getText();
				ctr.d.passPre = pass.getText();
				dialog.remove();
				ctr.a.isHasDialog.removeElementAt(0);
				createDialogLoading(stage, tweenManager);
				ctr.androidHelper.login(new IWMAction() {
					@Override
					public void action(String result) {
						// TODO Auto-generated method stub
						dimissDialogLoading();
						process.action(result);						
					}
				});
			}
		};		
		ChangeListener noLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();
				createDialogRegister(stage, tweenManager, new IWMAction() {
					@Override
					public void action(String result) {
						// TODO Auto-generated method stub
						if (result == null) {
							createDialog(stage,
									tweenManager, ctr.lang.connectError,
									1, null, null);
						} else {				
							 try{
							 JSONObject json = new JSONObject(result);

							 if(json.getString("code").equals("1")){											 
								 createDialog(stage, tweenManager, ctr.lang.registerOk, 1
										 ,new ChangeListener() {
												@Override
												public void changed(ChangeEvent event, Actor actor) {													
													createDialogLogin(stage, tweenManager,ctr.d.namePre,ctr.d.passPre, new IWMAction() {																	
														@Override
														public void action(String result) {
															// TODO Auto-generated method stub				
															process.action(result);
														}
													},backLoginLis,backRegLis,noRegLis);
												}
											}
										 ,null);
							 }
							 else{
								 createDialog(stage, tweenManager, ctr.lang.error+": "+json.getString("content"), 1, null, null);
							 }
							 }
							 catch(Exception ex){								 
							 }
						}
					}
				},noRegLis,backRegLis);
		}
		};
		
		ChangeListener backLoginLis1 = new ChangeListener() {
			
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();
				if(backLoginLis!=null)
					backLoginLis.changed(arg0, arg1);
			}
		};
		
		BackListener backLis = new BackListener(dialog, ok, no, okLis1, noLis1,backLoginLis1);
		ctr.d.backLis.add(backLis);
	}
	
	public void createDialogRegister(final Stage stage,final TweenManager tweenManager, final IWMAction process, final ChangeListener noButLis, final ChangeListener backKeyLis){
		ctr.a.isHasDialog.add(1);		
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (66), (20), (667), (440));
		final Table content = createTable(ctr.g.mSkin, (0), (0), (667), (440));
		Image bg = createImage(ctr.a.loginBgDialog_uof, 0, 0);
		bg.setSize((667*1.2f), (440*1.2f));
		bg.setOrigin(dialog.getWidth()/2, dialog.getHeight()/2);
		bg.setPosition((-67), (-44));
		
		Image dim = createImage(ctr.a.blackRegion, (-67), (-20),(800),(480));
		dim.setColor(0f, 0f, 0f, 0.6f);
		dialog.addActor(dim);
		dialog.addActor(bg);
		dialog.addActor(content);
		stage.addActor(dialog);
		bg.setScale(0.5f);
				
		final ImageButton ok = createImageButton(ctr.g.mSkin, ctr.a.regNorDialog_uof, ctr.a.regNorDialog_uof, null, 0, 0,143,43);
		ImageButton no = createImageButton(ctr.g.mSkin, ctr.a.noNorRegion, ctr.a.noPressRegion, null, 0, 0,143,43);					
			ok.setPosition((160), (40));
			content.addActor(ok);
			no.setPosition((340), (40));
			content.addActor(no);
			
		final TextField input = new TextField("", ctr.g.mSkin);		
		
		input.getStyle().font = ctr.g.mFont;
		input.getStyle().fontColor = Color.WHITE;
		input.setSize((250), (50));
		input.setMessageText(ctr.lang.user);
		input.setMaxLength(20);
		input.setPosition((200), (270));
		content.addActor(input);
		
		final TextField pass = new TextField("", ctr.g.mSkin);		
		pass.getStyle().font = ctr.g.mFont;
		pass.getStyle().fontColor = Color.WHITE;
		pass.setSize((250), (50));
		pass.setPasswordCharacter('*');
		pass.setPasswordMode(true);
		pass.setMessageText(ctr.lang.pass);		
		pass.setPosition((200), (210));
		content.addActor(pass);
		
		final TextField pass2 = new TextField("", ctr.g.mSkin);
		
		pass2.getStyle().font = ctr.g.mFont;
		pass2.getStyle().fontColor = Color.WHITE;
		pass2.setSize((250), (50));
		pass2.setPasswordCharacter('*');
		pass2.setPasswordMode(true);
		pass2.setMessageText(ctr.lang.confirmPass);
		pass2.setPosition((200), (150));
		content.addActor(pass2);
		
		ctr.inputTextAndroid.addTextField(input, true);
				
		ctr.inputTextAndroid.addTextField(pass, true);
		
		ctr.inputTextAndroid.addTextField(pass2, true);
		
		CheckBox male, female;
		male = createCheckBox((240), (100), 0, 0);
		female = createCheckBox(ctr.d.isVietnamese?(380):430, (100), 0, 0);
		
		
		ButtonGroup bet = new ButtonGroup();
		bet.add(male);
				
		bet.add(female);      
		
		//male.setChecked(false);
		//female.setChecked(true);
		
		content.addActor(createLabel(ctr.g.mFont, ctr.lang.male, Color.WHITE, (180), (100)));
		content.addActor(male);
		
		content.addActor(createLabel(ctr.g.mFont, ctr.lang.female, Color.WHITE, (340), (100)));
		content.addActor(female);
				
		content.setColor(1f,1f,1f,0f);
		
		Tween.to(bg, WidgetAccessor.OPACITY, 0.3f).target(1).ease(Quad.OUT).start(tweenManager);	
		Tween.to(bg, WidgetAccessor.SCALE_XY, 0.3f).target(1, 1).ease(Quad.OUT)		
		.setCallback(new TweenCallback() {
			
			@Override
			public void onEvent(int arg0, BaseTween<?> arg1) {
				// TODO Auto-generated method stub
				Tween.to(content, WidgetAccessor.OPACITY, 0.2f).target(1).ease(Quad.OUT).start(tweenManager);
			}
		})
		.start(tweenManager);	
		
		ChangeListener okLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {		
					
				if(ctr.androidHelper.isNetworkAvailable() == false){
					createDialog(stage, tweenManager, ctr.lang.turnOnNetworkForTask, 1, null, null);
					return;
				}
				
				if(input.getText().length() == 0 || pass.getText().length() == 0 || pass2.getText().length() == 0){
					ctr.androidHelper.showToast(ctr.lang.inputNotEnough);
					return;
				}
				
				if(!pass.getText().equals(pass2.getText())){
					ctr.androidHelper.showToast(ctr.lang.passwordNotSame);
					return;
				}
				
				ctr.d.namePre = input.getText();				
				ctr.d.passPre = pass.getText();
				
				dialog.remove();
				ctr.a.isHasDialog.removeElementAt(0);		
				createDialogLoading(stage, tweenManager);
				ctr.androidHelper.register(new IWMAction() {
										@Override
					public void action(String result) {
						// TODO Auto-generated method stub
						dimissDialogLoading();
						process.action(result);						
					}
				});
			}
		};		
		ChangeListener noLis1 = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {							
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();
				if(noButLis!=null)
					noButLis.changed(event, actor);
		}
		};
		
		ChangeListener backListener1 = new ChangeListener() {
			
			@Override
			public void changed(ChangeEvent arg0, Actor arg1) {
				// TODO Auto-generated method stub
				ctr.a.isHasDialog.removeElementAt(0);
				ctr.a.noSound.play(ctr.a.vls);
				dialog.remove();
				if(backKeyLis!=null)
					backKeyLis.changed(arg0, arg1);
			}
		};
		
		BackListener backLis = new BackListener(dialog, ok, no, okLis1, noLis1, backListener1);
		ctr.d.backLis.add(backLis);
	}

	
	public CheckBox createCheckBox(float x, float y, float wi, float hi){
		CheckBox tick = new CheckBox("", ctr.g.mSkin);
		tick.setPosition(x, y);
		return tick;
	} 
	
	public String cutString(BitmapFont bitmapFont, String text,
			float wiBound, float scale) {
		Label demo = createLabel(bitmapFont, text, Color.WHITE, 0, 0);
		demo.setFontScale(scale);
		String result = " ";
		String word = "";
		String charTemp;
		String fullWord = "";
		String fullWordTemp = "";
		int ln = text.length();

		for (int i = 0; i < ln; i++) {
			charTemp = text.substring(i, i + 1);
			if (charTemp.equals(" ")) {
				fullWordTemp = fullWord + word;
				demo.setText(fullWordTemp);
				if (demo.getTextBounds().width > wiBound) {
					result += fullWord + " \n ";
					fullWord = "";
					fullWord = fullWord + word + " ";
					word = "";
				} else {
					fullWord = fullWord + word + " ";
					word = "";
					if (i == ln - 1) {
						result += fullWord + " ";
					}
				}
			} else {
				word += charTemp;
				if (i == ln - 1) {
					fullWordTemp = fullWord + word;
					demo.setText(fullWordTemp);
					if (demo.getTextBounds().width > wiBound) {
						result += fullWord + " \n ";
						fullWord = "";
						fullWord = fullWord + word;
						result += fullWord + " ";
						word = "";
					} else {
						fullWord += word;
						result += fullWord;
					}
				}
			}
		}
		return result;
	}
	
	public Vector<String> cutString2(BitmapFont bitmapFont, String text,
			float wiBound, float scale) {
		Vector<String> result = new Vector<String>();
		Label demo = createLabel(bitmapFont, text, Color.WHITE, 0, 0);
		demo.setFontScale(scale);
		//String result = " ";
		String word = "";
		String charTemp;
		String fullWord = "";
		String fullWordTemp = "";
		int ln = text.length();

		for (int i = 0; i < ln; i++) {
			charTemp = text.substring(i, i + 1);
			if (charTemp.equals(" ")) {
				fullWordTemp = fullWord + word;
				demo.setText(fullWordTemp);
				if (demo.getTextBounds().width > wiBound) {
					//result += fullWord + " \n ";
					result.add(fullWord);
					fullWord = "";
					fullWord = fullWord + word + " ";
					word = "";
				} else {
					fullWord = fullWord + word + " ";
					word = "";
					if (i == ln - 1) {
						//result += fullWord + " ";
						result.add(fullWord);
					}
				}
			} else {
				word += charTemp;
				if (i == ln - 1) {
					fullWordTemp = fullWord + word;
					demo.setText(fullWordTemp);
					if (demo.getTextBounds().width > wiBound) {
						//result += fullWord + " \n ";
						result.add(fullWord);
						fullWord = "";
						fullWord = fullWord + word;
						//result += fullWord + " ";
						result.add(fullWord);
						word = "";
					} else {
						fullWord += word;
						//result += fullWord;
						result.add(fullWord);
					}
				}
			}
		}
		return result;
	}
	//======DRAW TUTORIAL==========
	int step;
	Tween tween1, tween2;
	

	public void createHelpMenu(final Stage stage, final TweenManager tweenManager){		
		ctr.a.isHasDialog.add(0);		
		ctr.d.backLis.removeAllElements();
		
		final Texture bgTexture = new Texture("data/help/bg_help_1.png");
		
		TextureRegion bgRegion = new TextureRegion(bgTexture);
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (800), (480));
		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (800), (480));	
		
		final Image bg = createImage(bgRegion,0, 0);
		
		final ImageButton trans = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 0, 0, 800, 480);
		
		final Image hand = createImage(ctr.a.hand, 32-21, 480-122-34);						
				
		final Label descript = createLabel(ctr.g.mFont, "Step TUT "+(step), Color.WHITE, 200, 100);
						
		descript.setPosition(32, 480-228);
		descript.setText(ctr.lang.menuHelp);					
		
		content.addActor(bg);
		content.addActor(hand);
		content.addActor(descript);			
		content.addActor(trans);
		
		dialog.addActor(content);
		
		stage.addActor(dialog);		
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(1).ease(Quad.OUT).start(tweenManager);
		
		 ChangeListener lis = new ChangeListener() {
				
				@Override
				public void changed(ChangeEvent arg0, Actor arg1) {
					
					// TODO Auto-generated method stub
					trans.setDisabled(true);
					Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(0).ease(Quad.OUT)
					.setCallback(new TweenCallback() {
						
						@Override
						public void onEvent(int arg0, BaseTween<?> arg1) {
							// TODO Auto-generated method st
							
								
							ctr.a.isHasDialog.removeElementAt(0);
							dialog.remove();							
							bgTexture.dispose();
						}
					})
					.start(tweenManager);				
				}
			};
		
		BackListener backLis = new BackListener(null, null, trans, null, lis, null);
		ctr.d.backLis.add(backLis);
		
	}
	
	public void createHelpDraw11(final Stage stage, final TweenManager tweenManager,final IMAction action){		
		
		ctr.a.isHasDialog.add(0);		
		ctr.d.backLis.removeAllElements();
			
		final Texture bgTexture = new Texture("data/help/bg_draw1_1.png");
		
		TextureRegion bgRegion = new TextureRegion(bgTexture);
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (800), (480));
		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (800), (480));	
		
		final Image bg = createImage(bgRegion,0, 0);
		
		final ImageButton trans = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 0, 0, 800, 480);
									
		final Label descript = createLabel(ctr.g.mFont, "Step TUT "+(step), Color.WHITE, 200, 100);
						
		descript.setPosition(189, 480-242);
		descript.setText(ctr.lang.draw1Help1);					
		
		content.addActor(bg);
		content.addActor(descript);			
		content.addActor(trans);
		
		dialog.addActor(content);
		
		stage.addActor(dialog);		
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(1).ease(Quad.OUT).start(tweenManager);
		
		
		 final ChangeListener lis = new ChangeListener() {
				
				@Override
				public void changed(ChangeEvent arg0, Actor arg1) {
					// TODO Auto-generated method stub
				
					trans.setDisabled(true);
					
					Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(0).ease(Quad.OUT)
					.setCallback(new TweenCallback() {
						
						@Override
						public void onEvent(int arg0, BaseTween<?> arg1) {
							// TODO Auto-generated method stub
							//if(ctr.a.isHasDialog.size()!=0)
							ctr.a.isHasDialog.removeElementAt(0);
							dialog.remove();
							bgTexture.dispose();
							action.action();
							
							ctr.stageHelper.createHelpDraw12(stage, tweenManager, new IMAction() {				
								@Override
								public void action() {
									// TODO Auto-generated method stub					
								}
							});			
						}
					})
					.start(tweenManager);				
				}
			};
		
		BackListener backLis = new BackListener(null, null, trans, null, lis, null);
		ctr.d.backLis.add(backLis);
		
	}
	
	
	public void createHelpDraw12(final Stage stage, final TweenManager tweenManager,final IMAction action){		
		ctr.a.isHasDialog.add(0);		
		ctr.d.backLis.removeAllElements();
		
		
		final Texture bgTexture = new Texture("data/help/bg_draw1_2.png");
		
		TextureRegion bgRegion = new TextureRegion(bgTexture);
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (800), (480));
		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (800), (480));	
		
		final Image bg = createImage(bgRegion,0, 0);
		
		final ImageButton trans = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 0, 0, 800, 480);
		
		final Image hand = createImage(ctr.a.hand, 452, 480-360);
		
		final Label descript = createLabel(ctr.g.mFont, "Step TUT "+(step), Color.WHITE, 200, 100);
						
		descript.setPosition(180, 480-70);
		descript.setText(ctr.lang.draw1Help2);					
		
		content.addActor(bg);
		content.addActor(descript);			
		content.addActor(hand);
		content.addActor(trans);
		
		
		dialog.addActor(content);
		
		stage.addActor(dialog);		
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(1).ease(Quad.OUT).start(tweenManager);
		
		final ChangeListener lis = new ChangeListener() {
				
				@Override
				public void changed(ChangeEvent arg0, Actor arg1) {
					// TODO Auto-generated method stub
					trans.setDisabled(true);
					
					Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(0).ease(Quad.OUT)
					.setCallback(new TweenCallback() {
						
						@Override
						public void onEvent(int arg0, BaseTween<?> arg1) {
							// TODO Auto-generated method stub
							ctr.a.isHasDialog.removeElementAt(0);
							dialog.remove();
							bgTexture.dispose();
							action.action();
							ctr.stageHelper.createHelpDraw13(stage, tweenManager, new IMAction() {				
								@Override
								public void action() {
									// TODO Auto-generated method stub					
								}
							});		
						}
					})
					.start(tweenManager);				
				}
			};
		
		BackListener backLis = new BackListener(null, null, trans, null, lis, null);
		ctr.d.backLis.add(backLis);
		
	}
	
	public void createHelpDraw13(final Stage stage, final TweenManager tweenManager,final IMAction action){		
		ctr.a.isHasDialog.add(0);		
		ctr.d.backLis.removeAllElements();
		
		final Texture bgTexture = new Texture("data/help/bg_draw1_3.png");
		
		TextureRegion bgRegion = new TextureRegion(bgTexture);
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (800), (480));
		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (800), (480));	
		
		final Image bg = createImage(bgRegion,0, 0);
		
		final ImageButton trans = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 0, 0, 800, 480);
		
		final Image hand = createImage(ctr.a.hand, 21, 480-453);
		
		final Label descript = createLabel(ctr.g.mFont, "Step TUT "+(step), Color.WHITE, 200, 100);
						
		
		descript.setPosition( 238, 480-348);
		descript.setText(ctr.lang.draw1Help3);					
		
		content.addActor(bg);
		content.addActor(descript);			
		content.addActor(hand);
		content.addActor(trans);
		
		
		dialog.addActor(content);
		
		stage.addActor(dialog);		
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(1).ease(Quad.OUT).start(tweenManager);
		
		final ChangeListener lis = new ChangeListener() {
				
				@Override
				public void changed(ChangeEvent arg0, Actor arg1) {
					// TODO Auto-generated method stub
					
					trans.setDisabled(true);
					
					Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(0).ease(Quad.OUT)
					.setCallback(new TweenCallback() {
						
						@Override
						public void onEvent(int arg0, BaseTween<?> arg1) {
							// TODO Auto-generated method stub
							ctr.a.isHasDialog.removeElementAt(0);
							dialog.remove();
							bgTexture.dispose();
							action.action();
							ctr.stageHelper.createHelpDraw14(stage, tweenManager, new IMAction() {				
								@Override
								public void action() {
									// TODO Auto-generated method stub					
								}
							});		
						}
					})
					.start(tweenManager);				
				}
			};
		
		BackListener backLis = new BackListener(null, null, trans, null, lis, null);
		ctr.d.backLis.add(backLis);
		
	}
	
	public void createHelpDraw14(final Stage stage, final TweenManager tweenManager,final IMAction action){		
		ctr.a.isHasDialog.add(0);		
		ctr.d.backLis.removeAllElements();

		final Texture bgTexture = new Texture("data/help/bg_draw1_4.png");
		
		TextureRegion bgRegion = new TextureRegion(bgTexture);
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (800), (480));
		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (800), (480));	
		
		final Image bg = createImage(bgRegion,0, 0);
		
		final ImageButton trans = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 0, 0, 800, 480);
		
		final Image hand = createImage(ctr.a.hand, 77, 480-243);
		
		final Label descript = createLabel(ctr.g.mFont, "Step TUT "+(step), Color.WHITE, 200, 100);
						
		
		descript.setPosition( 197, 480-190);
		descript.setText(ctr.lang.draw1Help4);					
		
		content.addActor(bg);
		content.addActor(descript);			
		content.addActor(hand);
		content.addActor(trans);
		
		
		dialog.addActor(content);
		
		stage.addActor(dialog);		
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(1).ease(Quad.OUT).start(tweenManager);
		
		 ChangeListener lis = new ChangeListener() {
				
				@Override
				public void changed(ChangeEvent arg0, Actor arg1) {
					// TODO Auto-generated method stub
					trans.setDisabled(true);
					Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(0).ease(Quad.OUT)
					.setCallback(new TweenCallback() {
						
						@Override
						public void onEvent(int arg0, BaseTween<?> arg1) {
							// TODO Auto-generated method stub
							ctr.a.isHasDialog.removeElementAt(0);
							dialog.remove();
							bgTexture.dispose();
							action.action();
							ctr.stageHelper.createHelpDraw15(stage, tweenManager, new IMAction() {				
								@Override
								public void action() {
									// TODO Auto-generated method stub					
								}
							});		
						}
					})
					.start(tweenManager);				
				}
			};
		
		BackListener backLis = new BackListener(null, null, trans, null, lis, null);
		ctr.d.backLis.add(backLis);
		
	}
	
	public void createHelpDraw15(final Stage stage, final TweenManager tweenManager,final IMAction action){		
		ctr.a.isHasDialog.add(0);		
		ctr.d.backLis.removeAllElements();
		final Texture bgTexture = new Texture("data/help/bg_draw1_5.png");
		
		TextureRegion bgRegion = new TextureRegion(bgTexture);
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (800), (480));
		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (800), (480));	
		
		final Image bg = createImage(bgRegion,0, 0);
		
		final ImageButton trans = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 0, 0, 800, 480);
		
		final Image hand = createImage(ctr.a.hand, 186, 480-210-40);
		
		final Label descript = createLabel(ctr.g.mFont, "Step TUT "+(step), Color.WHITE, 200, 100);
						
		
		descript.setPosition( 300, 480-197);
		descript.setText(ctr.lang.draw1Help5);					
		
		content.addActor(bg);
		content.addActor(descript);			
		content.addActor(hand);
		content.addActor(trans);
		
		
		dialog.addActor(content);
		
		stage.addActor(dialog);		
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(1).ease(Quad.OUT).start(tweenManager);
		
		 ChangeListener lis = new ChangeListener() {
				
				@Override
				public void changed(ChangeEvent arg0, Actor arg1) {
					// TODO Auto-generated method stub
					trans.setDisabled(true);
					Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(0).ease(Quad.OUT)
					.setCallback(new TweenCallback() {
						
						@Override
						public void onEvent(int arg0, BaseTween<?> arg1) {
							// TODO Auto-generated method stub
							
							ctr.a.isHasDialog.removeElementAt(0);
							dialog.remove();
							bgTexture.dispose();
							action.action();
							ctr.stageHelper.createHelpDraw16(stage, tweenManager, new IMAction() {				
								@Override
								public void action() {
									// TODO Auto-generated method stub					
								}
							});		
						}
					})
					.start(tweenManager);				
				}
			};
		
		BackListener backLis = new BackListener(null, null, trans, null, lis, null);
		ctr.d.backLis.add(backLis);
		
	}
	
	public void createHelpDraw16(final Stage stage, final TweenManager tweenManager,final IMAction action){		
		ctr.a.isHasDialog.add(0);		
		ctr.d.backLis.removeAllElements();
	
		final Texture bgTexture = new Texture("data/help/bg_draw1_6.png");
		
		TextureRegion bgRegion = new TextureRegion(bgTexture);
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (800), (480));
		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (800), (480));	
		
		final Image bg = createImage(bgRegion,0, 0);
		
		final ImageButton trans = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 0, 0, 800, 480);
		
		final Image hand = createImage(ctr.a.hand, 756-30, 480-229-50);
		
		final Label descript = createLabel(ctr.g.mFont, "Step TUT "+(step), Color.WHITE, 200, 100);
						
		
		descript.setPosition( 505-80, 480-214+50);
		descript.setText(ctr.lang.draw1Help6);					
		
		content.addActor(bg);
		content.addActor(descript);			
		content.addActor(hand);
		content.addActor(trans);
		
		
		dialog.addActor(content);
		
		stage.addActor(dialog);		
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(1).ease(Quad.OUT).start(tweenManager);
		
		 ChangeListener lis = new ChangeListener() {
				
				@Override
				public void changed(ChangeEvent arg0, Actor arg1) {
					// TODO Auto-generated method stub
					trans.setDisabled(true);
					
					Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(0).ease(Quad.OUT)
					.setCallback(new TweenCallback() {
						
						@Override
						public void onEvent(int arg0, BaseTween<?> arg1) {
							// TODO Auto-generated method stub
							ctr.a.isHasDialog.removeElementAt(0);
							dialog.remove();
							bgTexture.dispose();
							action.action();
							ctr.stageHelper.createHelpDraw17(stage, tweenManager, new IMAction() {				
								@Override
								public void action() {
									// TODO Auto-generated method stub					
								}
							});		
						}
					})
					.start(tweenManager);				
				}
			};
		
		BackListener backLis = new BackListener(null, null, trans, null, lis, null);
		ctr.d.backLis.add(backLis);
		
	}
	
	public void createHelpDraw17(final Stage stage, final TweenManager tweenManager,final IMAction action){		
		ctr.a.isHasDialog.add(0);		
		ctr.d.backLis.removeAllElements();
		
		final Texture bgTexture = new Texture("data/help/bg_draw1_7.png");
		
		TextureRegion bgRegion = new TextureRegion(bgTexture);
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (800), (480));
		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (800), (480));	
		
		final Image bg = createImage(bgRegion,0, 0);
		
		final ImageButton trans = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 0, 0, 800, 480);
		
		final Image hand = createImage(ctr.a.hand, 667, 480-179-50);
		
		final Label descript = createLabel(ctr.g.mFont, "Step TUT "+(step), Color.WHITE, 200, 100);
						
		
		descript.setPosition( 299-130, 480-263);
		descript.setText(ctr.lang.draw1Help7);					
		
		content.addActor(bg);
		content.addActor(descript);			
		content.addActor(hand);
		content.addActor(trans);
		
		
		dialog.addActor(content);
		
		stage.addActor(dialog);		
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(1).ease(Quad.OUT).start(tweenManager);
		
		 ChangeListener lis = new ChangeListener() {
				
				@Override
				public void changed(ChangeEvent arg0, Actor arg1) {
					trans.setDisabled(true);
					// TODO Auto-generated method stub
					Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(0).ease(Quad.OUT)
					.setCallback(new TweenCallback() {
						
						@Override
						public void onEvent(int arg0, BaseTween<?> arg1) {
							// TODO Auto-generated method stub
							
								
							ctr.a.isHasDialog.removeElementAt(0);
							dialog.remove();
							bgTexture.dispose();
							action.action();
							
							ctr.d.isHelpDraw1 = false;
							ctr.controller.getActivity().getPreference().saveValue("HelpDraw1", false);
						}
					})
					.start(tweenManager);				
				}
			};
		
		BackListener backLis = new BackListener(null, null, trans, null, lis, null);
		ctr.d.backLis.add(backLis);
		
	}
	
	public void createHelpDraw21(final Stage stage, final TweenManager tweenManager,final IMAction action){		
		ctr.a.isHasDialog.add(0);		
		ctr.d.backLis.removeAllElements();
		
		final Texture bgTexture = new Texture("data/help/draw3.png");
		
		TextureRegion bgRegion = new TextureRegion(bgTexture);
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (800), (480));
		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (800), (480));	
		
		final Image bg = createImage(bgRegion,0, 0);
		
		final ImageButton trans = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 0, 0, 800, 480);
		
		final Image hand = createImage(ctr.a.hand, 405, 480-309);
		
		final Label descript = createLabel(ctr.g.mFont, "Step TUT "+(step), Color.WHITE, 200, 100);
						
		
		descript.setPosition( 314, 480-62+7);
		descript.setText(ctr.lang.draw2Help1);					
		
		content.addActor(bg);
		content.addActor(descript);			
		content.addActor(hand);
		content.addActor(trans);
		
		
		dialog.addActor(content);
		
		stage.addActor(dialog);		
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(1).ease(Quad.OUT).start(tweenManager);
		
		 ChangeListener lis = new ChangeListener() {
				
				@Override
				public void changed(ChangeEvent arg0, Actor arg1) {
					// TODO Auto-generated method stub
					trans.setDisabled(true);
					Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(0).ease(Quad.OUT)
					.setCallback(new TweenCallback() {
						
						@Override
						public void onEvent(int arg0, BaseTween<?> arg1) {
							// TODO Auto-generated method stub
							ctr.a.isHasDialog.removeElementAt(0);
							dialog.remove();
							bgTexture.dispose();
							action.action();
						}
					})
					.start(tweenManager);				
				}
			};
		
		BackListener backLis = new BackListener(null, null, trans, null, lis, null);
		ctr.d.backLis.add(backLis);
		
	}
	
	public void createHelpDraw22(final Stage stage, final TweenManager tweenManager,final IMAction action){		
		ctr.a.isHasDialog.add(0);		
		ctr.d.backLis.removeAllElements();
		
		final Texture bgTexture = new Texture("data/help/draw4.png");
		
		TextureRegion bgRegion = new TextureRegion(bgTexture);
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (800), (480));
		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (800), (480));	
		
		final Image bg = createImage(bgRegion,0, 0);
		
		final ImageButton trans = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 0, 0, 800, 480);
		
		final Image hand = createImage(ctr.a.hand, 37+50, 480-429);
		
		final Label descript = createLabel(ctr.g.mFont, "Step TUT "+(step), Color.WHITE, 200, 100);						
		
		descript.setPosition( 206, 480-383);
		descript.setText(ctr.lang.draw2Help2);					
		
		content.addActor(bg);
		content.addActor(descript);			
		content.addActor(hand);
		content.addActor(trans);
		
		
		dialog.addActor(content);
		
		stage.addActor(dialog);		
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(1).ease(Quad.OUT).start(tweenManager);
		
		 ChangeListener lis = new ChangeListener() {
				
				@Override
				public void changed(ChangeEvent arg0, Actor arg1) {
					trans.setDisabled(true);
					// TODO Auto-generated method stub
					Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(0).ease(Quad.OUT)
					.setCallback(new TweenCallback() {
						
						@Override
						public void onEvent(int arg0, BaseTween<?> arg1) {
							// TODO Auto-generated method stub
							ctr.a.isHasDialog.removeElementAt(0);
							dialog.remove();
							bgTexture.dispose();
							action.action();
						}
					})
					.start(tweenManager);				
				}
			};
		
		BackListener backLis = new BackListener(null, null, trans, null, lis, null);
		ctr.d.backLis.add(backLis);		
	}
	
	public void createHelpDraw23(final Stage stage, final TweenManager tweenManager,final IMAction action){		
		ctr.a.isHasDialog.add(0);		
		ctr.d.backLis.removeAllElements();
		final Texture bgTexture = new Texture("data/help/draw5.png");
		
		TextureRegion bgRegion = new TextureRegion(bgTexture);
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (800), (480));
		
		final Table content = createTable(ctr.g.mSkin, (0), (0), (800), (480));	
		
		final Image bg = createImage(bgRegion,0, 0);
		
		final ImageButton trans = createImageButton(ctr.g.mSkin, ctr.a.transRegion, null, null, 0, 0, 800, 480);
		
		final Image hand = createImage(ctr.a.hand, 747-20, 480-245-40);
		
		final Label descript = createLabel(ctr.g.mFont, "Step TUT "+(step), Color.WHITE, 200, 100);
						
		
		descript.setPosition( 508-100, 480-173+30);
		descript.setText(ctr.lang.draw2Help3);					
		
		content.addActor(bg);
		content.addActor(descript);			
		content.addActor(hand);
		content.addActor(trans);
		
		
		dialog.addActor(content);
		
		stage.addActor(dialog);		
		
		content.setColor(1f, 1f, 1f, 0f);
		Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(1).ease(Quad.OUT).start(tweenManager);
		
		 ChangeListener lis = new ChangeListener() {
				
				@Override
				public void changed(ChangeEvent arg0, Actor arg1) {
					// TODO Auto-generated method stub
					trans.setDisabled(true);
					Tween.to(content, WidgetAccessor.OPACITY, 0.4f).target(0).ease(Quad.OUT)
					.setCallback(new TweenCallback() {
						
						@Override
						public void onEvent(int arg0, BaseTween<?> arg1) {
							// TODO Auto-generated method stub
								
							ctr.a.isHasDialog.removeElementAt(0);
							dialog.remove();
							bgTexture.dispose();
							action.action();
						}
					})
					.start(tweenManager);				
				}
			};
		
		BackListener backLis = new BackListener(null, null, trans, null, lis, null);
		ctr.d.backLis.add(backLis);
		
	}
	
	public void createDrawTutorial(final Stage stage, final TweenManager tweenManager){		
				
		step = 1;
		final int maxTut = 5;
		
		ctr.a.isHasDialog.add(0);		
		ctr.d.backLis.removeAllElements();
		
		final Table dialog = createTable(ctr.g.mSkin, (0), (0), (800), (480));
		final Table content = createTable(ctr.g.mSkin, (0), (0), (800), (480));	
				
		final Image bgText = createImage(ctr.a.sticky, 0, 0);
		
		final ImageButton next = createImageButton(ctr.g.mSkin, ctr.a.blankSmallButton, null, null, 800-73, 0,73,73);
		
		TextureRegion arrowUp = new TextureRegion(ctr.a.arrowDown);		
		arrowUp.flip(false, true);
		
		TextureRegion arrowRight = new TextureRegion(ctr.a.arrowLeft);		
		arrowRight.flip(true, false);
		
		final Image right = createImage(arrowRight, 0, 0);						
		
		tween1 = Tween.to(right, WidgetAccessor.POS_XY, 0.5f)
		.targetRelative(30, 0)
		.repeatYoyo(-1, 0.1f);		
		tween1.start(tweenManager);
		
		final Image left = createImage(ctr.a.arrowLeft, 0, 0);		
		
		tween2 = Tween.to(left, WidgetAccessor.POS_XY, 0.5f)
		.targetRelative(-30, 0)
		.repeatYoyo(-1, 0.1f);
		
		tween2.start(tweenManager);
		
		final Image rightStatic = createImage(arrowRight, 0, 0);	
		final Image leftStatic = createImage(ctr.a.arrowLeft, 0, 0);	
		
		final Image upStatic = createImage(arrowUp, 0, 0);	
		final Image downStatic = createImage(ctr.a.arrowDown, 0, 0);
		
		final Label descript = createLabel(ctr.g.mFont, "Step TUT "+(step), Color.WHITE, 200, 100);
				
		ChangeListener nextLis = new ChangeListener() {
			@Override
			public void changed(ChangeEvent event, Actor actor) {			
				step++;				
				switch (step) {						
				case 2:
					rightStatic.setVisible(true);
					leftStatic.setVisible(true);
					right.setVisible(false);
					rightStatic.setPosition(498, 192);
					leftStatic.setPosition(376, 192);
					bgText.setPosition(384, 0);					
					descript.setText("Chọn một map" +
							"\nđã vẽ, click" +
							"\nđể chơi");
					descript.setPosition(384+10, 100);
					next.setPosition(430, 0);
					break;
				case 3:
					rightStatic.setVisible(false);
					leftStatic.setVisible(false);
					upStatic.setVisible(true);
					downStatic.setVisible(true);
					upStatic.setPosition(130, 191);
					downStatic.setPosition(130, 96);
					bgText.setPosition(189, 65);
					descript.setText("Click một icon\nđể thay chủ\nđề của map\nhiện tại");
					bgText.setSize(191, 195);
					descript.setPosition(189+10, 65+100);
					next.setPosition(235, 43);
					break;
				case 4:
					left.setVisible(true);
					rightStatic.setVisible(false);
					leftStatic.setVisible(false);
					upStatic.setVisible(false);
					downStatic.setVisible(false);
					bgText.setPosition(154, 480-364);
					left.setPosition(172, 480-164);
					descript.setText("Click nâng cấp\nhọa sĩ Gome\ncủa bạn để\nlưu nhiều map\n hơn");					
					descript.setPosition(154+10, 480-364+100);
					next.setPosition(194, 480-333);
					break;
				case 5:
					tween1.kill();
					tween1.free();
					tween1 = null;
					
					left.setVisible(false);
					right.setVisible(true);
					right.setPosition(633, 480-183);										
					rightStatic.setVisible(false);
					leftStatic.setVisible(false);
					upStatic.setVisible(false);
					downStatic.setVisible(false);
					bgText.setPosition(613, 480-379);
					descript.setText("Click để xóa\nmap hiện tại");
					descript.setPosition(613+10, 480-379+100);
					next.setPosition(679, 480-365);
					
					tween1 = Tween.to(right, WidgetAccessor.POS_XY, 0.5f)
							.targetRelative(30, 0)
							.repeatYoyo(-1, 0.1f);		
					tween1.start(tweenManager);
					
					break;
				}					
				if(step<=maxTut){
				}
				else{
					dialog.remove();					
					ctr.a.isHasDialog.removeElementAt(0);						
				}						
			}
		};
		

		switch (step) {		
		case 1:
			left.setVisible(false);
			upStatic.setVisible(false);
			downStatic.setVisible(false);
			leftStatic.setVisible(false);
			rightStatic.setVisible(false);
			bgText.setPosition(597, 480-307);					
			descript.setPosition(597+10, 480-307+100);
			right.setPosition(523, 374);
			descript.setText("Click để tạo \nmap mới");			
			bgText.setSize(191, 195);
			next.setPosition(650, 180);
			break;
		}	
		
		
		content.addActor(bgText);
		next.addListener(nextLis);		
		content.addActor(descript);		
		content.addActor(right);
		content.addActor(left);
		content.addActor(leftStatic);
		content.addActor(rightStatic);
		content.addActor(upStatic);
		content.addActor(downStatic);
		content.addActor(next);
		dialog.addActor(content);		
		stage.addActor(dialog);		
	}

	final String[] arrayVi = {"Nhập môn","Tập sự", "Cao thủ","Cao cấp", "Siêu cấp"};
	final String[] arrayEn = {"Level I","Level II", "Level III","Level IV", "Level V"};
	
	public void starGen(Table actor, int x, int y, int star, int type, int style, boolean isHasText, String text, int exp){		
		
				
		int[] starMax = {3,4,5,7,9};
		

		
		TextureRegion region;
		boolean is2Line = false;
		
		style = 2;
		
		Image bg = createImage(ctr.a.bgAchieve, x, y,256,84);
		bg.setColor(0.5f,0.5f,0.5f,0.5f);
		
		
		actor.addActor(bg);
		
		Image[] stars = new Image[starMax[type]];
		region = ctr.a.star[type];
		
		if(is2Line == false){
			for(int i=0;i<starMax[type]; i++){
				boolean isAction;
				if(i<star){
					stars[i] = createImage(region, x+84+i*16, y+84-20);
					isAction = true;
				}
				else{
					stars[i] = createImage(region, x+84+i*16, y+84-20);
					stars[i].setColor(0.5f, 0.5f, 0.5f, 1f);					
					isAction = true;
				}
			}
		}
				
		for(int i=0;i<starMax[type]; i++){
			actor.addActor(stars[i]);			
		}		
				
		
		actor.addActor(createImage(ctr.a.achievement[type], x, y,84,84));				
		
		if(isHasText){
		if(is2Line == false){
			actor.addActor(createLabel(ctr.g.mFont, "Exp:"+exp, Color.WHITE, x+84, y+5+ctr.g.mFont.getLineHeight()));
			actor.addActor(createLabel(ctr.g.mFont, ctr.d.isVietnamese?arrayVi[type]:arrayEn[type], Color.WHITE, x+84, y+5));			
		}
		else{
			actor.addActor(createLabel(ctr.g.mFont, text, Color.WHITE, x+79, y-2*16-30));
		}
		}
	}
	
	public Table starGenHelp(int type){		
		int[] starAs = {3,4,5,7,9};
		Table actor= createTableWithTransBg(ctr.g.mSkin, 0, 0, 256+100, 84);
		int x=0,y=0;
		TextureRegion region;
		boolean is2Line = false;
		
		int star = starAs[type];
		
		Image bg = createImage(ctr.a.bgAchieve, x, y,256+100,84);
		bg.setColor(0.5f,0.5f,0.5f,0.5f);
		
		
		actor.addActor(bg);
		
		Image[] stars = new Image[star];
		region = ctr.a.star[type];
		
		if(is2Line == false){
			for(int i=0;i<star; i++){
				stars[i] = createImage(region, x+84+i*16, y+84-16-10);
			}
		}
				
		for(int i=0;i<star; i++){
			actor.addActor(stars[i]);
		}		
				
		
		actor.addActor(createImage(ctr.a.achievement[type], x, y,84,84));				

		if(is2Line == false){
			//actor.addActor(createLabel(ctr.g.mFont, "Exp:", Color.WHITE, x+84, y+5+ctr.g.mFont.getLineHeight()));
			actor.addActor(createLabel(ctr.g.mFont, ctr.d.isVietnamese?arrayVi[type]:arrayEn[type], Color.WHITE, x+84, y+5+10));			
		}		
		
		return actor;
	}
}